From fbb1fabef04bafd4b99ca996d45ebc42e3254bdf Mon Sep 17 00:00:00 2001 From: Craig Roberts Date: Sat, 24 Oct 2015 16:22:09 +0800 Subject: [PATCH] Support custom element types via type extensions - Moved `props` up to make it accessible before element instantiation - Added a type variable, which is either the value of `properties.attributes.is` or `null` - Amended `doc.createElement` to supply the second parameter for type extensions --- vdom/create-element.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vdom/create-element.js b/vdom/create-element.js index 23353cc2..75f72d85 100644 --- a/vdom/create-element.js +++ b/vdom/create-element.js @@ -26,11 +26,13 @@ function createElement(vnode, opts) { return null } + var props = vnode.properties + var type = props && props.attributes && props.attributes.is || null + var node = (vnode.namespace === null) ? - doc.createElement(vnode.tagName) : - doc.createElementNS(vnode.namespace, vnode.tagName) + doc.createElement(vnode.tagName, type) : + doc.createElementNS(vnode.namespace, vnode.tagName, type) - var props = vnode.properties applyProperties(node, props) var children = vnode.children