UNPKG

mostly-dom

Version:
42 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.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, exports.SVG_NAMESPACE); }; return MostlyVNode; }()); exports.MostlyVNode = MostlyVNode; function addSvgNamespace(vNode) { vNode.namespace = exports.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); } } } exports.addSvgNamespace = addSvgNamespace; //# sourceMappingURL=VNode.js.map