From 55f3d6d3af65df178f2a2d608a19f463f62a2a3e Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 15 Apr 2016 23:19:05 -0400 Subject: [PATCH] include full html element list --- src/runtime/util/dom.js | 42 ++++++++++-------------------- src/runtime/vdom/create-element.js | 15 +++++------ 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/src/runtime/util/dom.js b/src/runtime/util/dom.js index 626342aa..bbfc7d68 100644 --- a/src/runtime/util/dom.js +++ b/src/runtime/util/dom.js @@ -1,7 +1,20 @@ import { isIE9 } from './env' import { warn } from './debug' -const reservedTags = 'slot|component|div|p|span|img|a|b|i|br|ul|ol|li|h1|h2|h3|h4|h5|h6|code|pre|table|th|td|tr|form|label|input|select|option|nav|article|section|header|footer' +const reservedTags = + 'slot|component|' + + 'html|base|head|link|meta|style|title|' + + 'address|article|footer|header|h1|h2|h3|h4|h5|h6|hgroup|nav|section|' + + 'div|dd|dl|dt|figcaption|figure|hr|li|main|ol|p|pre|ul|' + + 'a|b|abbr|bdi|bdo|br|cite|code|data|dfn|em|i|kbd|mark|q|rp|rt|rtc|ruby|' + + 's|samp|small|span|strong|sub|sup|time|u|var|wbr|area|audio|map|track|video|' + + 'embed|object|param|source|canvas|script|noscript|del|ins|' + + 'caption|col|colgroup|table|thead|tbody|td|th|tr|' + + 'button|datalist|fieldset|form|input|label|legend|meter|optgroup|option|' + + 'output|progress|select|textarea|' + + 'details|dialog|menu|menuitem|summary|' + + 'content|element|shadow|template' + const reservedTagMap = Object.create(null) reservedTags.split('|').forEach(tag => { reservedTagMap[tag] = true @@ -11,33 +24,6 @@ export function isReservedTag (tag) { return reservedTagMap[tag] } -export let isUnknownElement -if (process.env.NODE_ENV !== 'production') { - isUnknownElement = (function () { - const cache = {} - return function (tag) { - if (cache.hasOwnProperty(tag)) { - return cache[tag] - } - const el = document.createElement(tag) - if (tag.indexOf('-') > -1) { - // http://stackoverflow.com/a/28210364/1070244 - return ( - el.constructor === window.HTMLUnknownElement || - el.constructor === window.HTMLElement - ) - } else { - return ( - /HTMLUnknownElement/.test(el.toString()) && - // Chrome returns unknown for several HTML5 elements. - // https://code.google.com/p/chromium/issues/detail?id=540526 - !/^(data|time|rtc|rb)$/.test(tag) - ) - } - } - })() -} - /** * Query an element selector if it's not an element already. * diff --git a/src/runtime/vdom/create-element.js b/src/runtime/vdom/create-element.js index e56f87c6..4e05bd57 100644 --- a/src/runtime/vdom/create-element.js +++ b/src/runtime/vdom/create-element.js @@ -6,7 +6,6 @@ import { isPrimitive, isArray, isReservedTag, - isUnknownElement, resolveAsset } from '../util/index' @@ -20,14 +19,12 @@ export default function createElement (tag, data, children) { } else if ((Ctor = resolveAsset(parent.$options, 'components', tag))) { return Component(Ctor, data, parent, children) } else { - if (process.env.NODE_ENV !== 'production') { - if (!data.svg && isUnknownElement(tag)) { - warn( - 'Unknown custom element: <' + tag + '> - did you ' + - 'register the component correctly? For recursive components, ' + - 'make sure to provide the "name" option.' - ) - } + if (process.env.NODE_ENV !== 'production' && !data.svg) { + warn( + 'Unknown custom element: <' + tag + '> - did you ' + + 'register the component correctly? For recursive components, ' + + 'make sure to provide the "name" option.' + ) } return VNode(tag, data, children) }