UNPKG

@muban/muban

Version:

Writing components for server-rendered HTML

25 lines (24 loc) 1.06 kB
import { convertSourceValue } from './convertSourceValue'; export function createTextPropertySource() { return () => { return { sourceName: 'text', hasProp: (propInfo) => Boolean(propInfo.source.target), getProp: (propInfo) => { var _a, _b; let value; const rawValue = propInfo.type !== Function ? (_b = (_a = propInfo.source.target) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined : undefined; if (rawValue !== undefined) { value = convertSourceValue(propInfo, rawValue); } else if (propInfo.type === Boolean) { // TODO: output warning about undefined booleans once we document // how these should behave for all type of sources // eslint-disable-next-line no-console console.warn(); } return value; }, }; }; }