Comparing version 1.6.3 to 1.6.4
@@ -103,3 +103,3 @@ 'use strict'; | ||
var registeredElements = {}; | ||
var customElementsRegistry = global._customElementsRegistry = global._customElementsRegistry || {}; | ||
@@ -109,6 +109,6 @@ var originalCreateElement = Document.prototype.createElement; | ||
tagName = tagName.toLowerCase(); | ||
var customElProto = registeredElements[tagName]; | ||
var customElClass = customElementsRegistry[tagName]; | ||
var el = void 0; | ||
if (customElProto) { | ||
el = new customElProto(); | ||
if (customElClass) { | ||
el = new customElClass(); | ||
el.nodeName = el.tagName = tagName; | ||
@@ -122,10 +122,13 @@ } else { | ||
global.customElements = global.customElements || { | ||
get: function get(tagName) { | ||
return customElementsRegistry[tagName]; | ||
}, | ||
define: function define(tagName, proto) { | ||
tagName = tagName.toLowerCase(); | ||
if (registeredElements[tagName]) { | ||
throw DOMException('Registration failed for type \'' + tagName + '\'. A type with that name is already registered.'); | ||
if (customElementsRegistry[tagName]) { | ||
throw new Error('Registration failed for type \'' + tagName + '\'. A type with that name is already registered.'); | ||
} else { | ||
registeredElements[tagName] = proto; | ||
customElementsRegistry[tagName] = proto; | ||
} | ||
} | ||
}; |
@@ -71,3 +71,3 @@ /* eslint-env node */ | ||
const registeredElements = {}; | ||
const customElementsRegistry = global._customElementsRegistry = global._customElementsRegistry || {}; | ||
@@ -77,6 +77,6 @@ const originalCreateElement = Document.prototype.createElement; | ||
tagName = tagName.toLowerCase(); | ||
const customElProto = registeredElements[tagName]; | ||
const customElClass = customElementsRegistry[tagName]; | ||
let el; | ||
if (customElProto) { | ||
el = new customElProto(); | ||
if (customElClass) { | ||
el = new customElClass(); | ||
el.nodeName = el.tagName = tagName; | ||
@@ -90,10 +90,14 @@ } else { | ||
global.customElements = global.customElements || { | ||
get(tagName) { | ||
return customElementsRegistry[tagName]; | ||
}, | ||
define(tagName, proto) { | ||
tagName = tagName.toLowerCase(); | ||
if (registeredElements[tagName]) { | ||
throw DOMException(`Registration failed for type '${tagName}'. A type with that name is already registered.`); | ||
if (customElementsRegistry[tagName]) { | ||
throw new Error(`Registration failed for type '${tagName}'. A type with that name is already registered.`); | ||
} else { | ||
registeredElements[tagName] = proto; | ||
customElementsRegistry[tagName] = proto; | ||
} | ||
}, | ||
}; |
{ | ||
"name": "panel", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "Web Components with Virtual DOM: lightweight composable web apps", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
128989
2718