UNPKG

mostly-dom

Version:
39 lines 1.54 kB
export var SVG_NAMESPACE = "http://www.w3.org/2000/svg"; var defaultTextNodeData = {}; var MostlyVNode = /** @class */ (function () { function MostlyVNode(tagName, props, children, element, text, key, scope, namespace) { this.tagName = tagName; this.props = props; this.children = children; this.element = element; this.text = text; this.key = key; this.scope = scope; this.namespace = namespace; this.parent = undefined; } MostlyVNode.create = function (tagName, props, children, text) { return new MostlyVNode(tagName, props, children, undefined, text, props.key, props.scope, undefined); }; MostlyVNode.createText = function (text) { return new MostlyVNode(undefined, defaultTextNodeData, undefined, undefined, text, undefined, undefined, undefined); }; MostlyVNode.createSvg = function (tagName, props, children, text) { return new MostlyVNode(tagName, props, children, undefined, text, props.key, props.scope, SVG_NAMESPACE); }; return MostlyVNode; }()); export { MostlyVNode }; export function addSvgNamespace(vNode) { vNode.namespace = SVG_NAMESPACE; if (Array.isArray(vNode.children)) { var children = vNode.children; var childCount = children.length; for (var i = 0; i < childCount; ++i) { var child = children[i]; if (child.tagName !== 'foreignObject') addSvgNamespace(child); } } } //# sourceMappingURL=VNode.js.map