Permalink
Browse files

fixed #66 and improved #67

  • Loading branch information...
1 parent 14cdb06 commit 0e98e6482e34d6e7ba5c7845ca64347ed223c284 @WebReflection committed Aug 24, 2016
View
@@ -1,4 +1,5 @@
-Copyright (C) 2014-2015 by WebReflection
+
+Copyright (C) 2014-2016 by Andrea Giammarchi - @WebReflection
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
@@ -1,7 +1,7 @@
{
"name": "document-register-element",
"description": "A stand-alone working lightweight version of the W3C Custom Elements specification",
- "main": "./build/document-register-element.js",
+ "main": "./build/document-register-element.max.js",
"ignore": [
"test",
".jshintrc",
Oops, something went wrong.
Oops, something went wrong.
@@ -1,5 +1,6 @@
/*!
-Copyright (C) 2014-2015 by WebReflection
+
+Copyright (C) 2014-2016 by Andrea Giammarchi - @WebReflection
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -552,6 +553,7 @@ var
constructors = Dict(null),
waitingList = Dict(null),
nodeNames = new Map(),
+ secondArgument = String,
// used to create unique instances
create = Object.create || function Bridge(proto) {
@@ -985,7 +987,7 @@ if (!(REGISTER_ELEMENT in document)) {
var
is = typeof typeExtension === 'string' ? typeExtension : '',
node = is ?
- createElement.call(document, localName, is) :
+ createElement.call(document, localName, secondArgument(is)) :
createElement.call(document, localName),
name = '' + localName,
i = indexOf.call(
@@ -1183,7 +1185,7 @@ CustomElementRegistry.prototype = {
define: usableCustomElements ?
function (name, Class, options) {
if (options) {
- define(name, Class, options);
+ CERDefine(name, Class, options);
} else {
customElements.define(name, Class);
name = name.toUpperCase();
@@ -1194,7 +1196,7 @@ CustomElementRegistry.prototype = {
nodeNames.set(Class, name);
}
} :
- define,
+ CERDefine,
get: usableCustomElements ?
function (name) {
return customElements.get(name) || get(name);
@@ -1210,7 +1212,7 @@ CustomElementRegistry.prototype = {
whenDefined
};
-function define(name, Class, options) {
+function CERDefine(name, Class, options) {
var
is = options && options[EXTENDS] || '',
CProto = Class.prototype,
@@ -1256,7 +1258,7 @@ function define(name, Class, options) {
name = name.toUpperCase();
constructors[name] = {
constructor: Class,
- create: is ? [is, name] : [name]
+ create: is ? [is, secondArgument(name)] : [name]
};
nodeNames.set(Class, name);
whenDefined(name);
@@ -1345,7 +1347,7 @@ function polyfillV1() {
var is = typeof options === 'string' ?
options : (options && options.is || '');
return is ?
- patchedCreateElement.call(this, name, is) :
+ patchedCreateElement.call(this, name, secondArgument(is)) :
patchedCreateElement.call(this, name);
});
}
@@ -1369,4 +1371,12 @@ try {
} catch(o_O) {
polyfillV1();
}
+
+try {
+ createElement.call(document, 'a', 'a');
+} catch(FireFox) {
+ secondArgument = function (is) {
+ return {is: is};
+ };
+}
});
@@ -1,5 +1,6 @@
/*!
-Copyright (C) 2014-2015 by WebReflection
+
+Copyright (C) 2014-2016 by Andrea Giammarchi - @WebReflection
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -550,6 +551,7 @@ var
constructors = Dict(null),
waitingList = Dict(null),
nodeNames = new Map(),
+ secondArgument = String,
// used to create unique instances
create = Object.create || function Bridge(proto) {
@@ -983,7 +985,7 @@ if (!(REGISTER_ELEMENT in document)) {
var
is = typeof typeExtension === 'string' ? typeExtension : '',
node = is ?
- createElement.call(document, localName, is) :
+ createElement.call(document, localName, secondArgument(is)) :
createElement.call(document, localName),
name = '' + localName,
i = indexOf.call(
@@ -1181,7 +1183,7 @@ CustomElementRegistry.prototype = {
define: usableCustomElements ?
function (name, Class, options) {
if (options) {
- define(name, Class, options);
+ CERDefine(name, Class, options);
} else {
customElements.define(name, Class);
name = name.toUpperCase();
@@ -1192,7 +1194,7 @@ CustomElementRegistry.prototype = {
nodeNames.set(Class, name);
}
} :
- define,
+ CERDefine,
get: usableCustomElements ?
function (name) {
return customElements.get(name) || get(name);
@@ -1208,7 +1210,7 @@ CustomElementRegistry.prototype = {
whenDefined
};
-function define(name, Class, options) {
+function CERDefine(name, Class, options) {
var
is = options && options[EXTENDS] || '',
CProto = Class.prototype,
@@ -1254,7 +1256,7 @@ function define(name, Class, options) {
name = name.toUpperCase();
constructors[name] = {
constructor: Class,
- create: is ? [is, name] : [name]
+ create: is ? [is, secondArgument(name)] : [name]
};
nodeNames.set(Class, name);
whenDefined(name);
@@ -1343,7 +1345,7 @@ function polyfillV1() {
var is = typeof options === 'string' ?
options : (options && options.is || '');
return is ?
- patchedCreateElement.call(this, name, is) :
+ patchedCreateElement.call(this, name, secondArgument(is)) :
patchedCreateElement.call(this, name);
});
}
@@ -1368,4 +1370,12 @@ try {
polyfillV1();
}
+try {
+ createElement.call(document, 'a', 'a');
+} catch(FireFox) {
+ secondArgument = function (is) {
+ return {is: is};
+ };
+}
+
}(window, document, Object, 'registerElement'));
@@ -1,2 +1,2 @@
-/*! (C) WebReflection Mit Style License */
+/*! (C) Andrea Giammarchi - @WebReflection - Mit Style License */
(function(e,t,n){if(n in e)return;var r=0,i=e.clearTimeout,s=e.setTimeout,o=Element.prototype,u=t.getOwnPropertyDescriptor,a=t.defineProperty,f=function(){document.dispatchEvent(new CustomEvent("readystatechange"))},l=function(e,t){i(r),r=s(f,10)},c=function(e){var t=u(o,e),n={configurable:t.configurable,enumerable:t.enumerable,get:function(){return t.get.call(this)},set:function(r){delete o[e],this[e]=r,a(o,e,n),l(this)}};a(o,e,n)},h=function(e){var t=u(o,e),n=t.value;t.value=function(){var e=n.apply(this,arguments);return l(this),e},a(o,e,t)};c("innerHTML"),c("innerText"),c("outerHTML"),c("outerText"),c("textContent"),h("appendChild"),h("applyElement"),h("insertAdjacentElement"),h("insertAdjacentHTML"),h("insertAdjacentText"),h("insertBefore"),h("insertData"),h("replaceAdjacentText"),h("replaceChild"),h("removeChild"),e[n]=Element})(window,Object,"HTMLElement");
@@ -1,5 +1,6 @@
/*!
-Copyright (C) 2014-2015 by WebReflection
+
+Copyright (C) 2014-2016 by Andrea Giammarchi - @WebReflection
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
@@ -1,3 +1,3 @@
-/*! (C) WebReflection Mit Style License */
+/*! (C) Andrea Giammarchi - @WebReflection - Mit Style License */
// see https://github.com/WebReflection/document-register-element/issues/21#issuecomment-102020311
var innerHTML=function(e){var t="extends",n=e.registerElement,r=e.createElement("div"),i="document-register-element",s=n.innerHTML,o,u;if(s)return s;try{n.call(e,i,{prototype:Object.create(HTMLElement.prototype,{createdCallback:{value:Object}})}),r.innerHTML="<"+i+"></"+i+">";if("createdCallback"in r.querySelector(i))return n.innerHTML=function(e,t){return e.innerHTML=t,e}}catch(a){}return u=[],o=function(t){if("createdCallback"in t||"attachedCallback"in t||"detachedCallback"in t||"attributeChangedCallback"in t)return;e.createElement.innerHTMLHelper=!0;for(var n=t.parentNode,r=t.getAttribute("is"),i=t.nodeName,s=e.createElement.apply(e,r?[i,r]:[i]),o=t.attributes,u=0,a=o.length,f,l;u<a;u++)f=o[u],s.setAttribute(f.name,f.value);s.createdCallback&&(s.created=!0,s.createdCallback(),s.created=!1);while(l=t.firstChild)s.appendChild(l);e.createElement.innerHTMLHelper=!1,n&&n.replaceChild(s,t)},(e.registerElement=function(i,s){var o=(s[t]?s[t]+'[is="'+i+'"]':i).toLowerCase();return u.indexOf(o)<0&&u.push(o),n.apply(e,arguments)}).innerHTML=function(e,t){e.innerHTML=t;for(var n=e.querySelectorAll(u.join(",")),r=n.length;r--;o(n[r]));return e}}(document);
@@ -1,5 +1,6 @@
/*!
-Copyright (C) 2014-2015 by WebReflection
+
+Copyright (C) 2014-2016 by Andrea Giammarchi - @WebReflection
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
@@ -24,7 +24,7 @@
"type": "git",
"url": "git://github.com/WebReflection/document-register-element.git"
},
- "main": "./build/document-register-element.js",
+ "main": "./build/document-register-element.max.js",
"scripts": {
"test": "phantomjs testrunner.js",
"web": "node node_modules/tiny-cdn/tiny-cdn run -p=1337"
@@ -128,6 +128,7 @@ var
constructors = Dict(null),
waitingList = Dict(null),
nodeNames = new Map(),
+ secondArgument = String,
// used to create unique instances
create = Object.create || function Bridge(proto) {
@@ -561,7 +562,7 @@ if (!(REGISTER_ELEMENT in document)) {
var
is = typeof typeExtension === 'string' ? typeExtension : '',
node = is ?
- createElement.call(document, localName, is) :
+ createElement.call(document, localName, secondArgument(is)) :
createElement.call(document, localName),
name = '' + localName,
i = indexOf.call(
@@ -759,7 +760,7 @@ CustomElementRegistry.prototype = {
define: usableCustomElements ?
function (name, Class, options) {
if (options) {
- define(name, Class, options);
+ CERDefine(name, Class, options);
} else {
customElements.define(name, Class);
name = name.toUpperCase();
@@ -770,7 +771,7 @@ CustomElementRegistry.prototype = {
nodeNames.set(Class, name);
}
} :
- define,
+ CERDefine,
get: usableCustomElements ?
function (name) {
return customElements.get(name) || get(name);
@@ -786,7 +787,7 @@ CustomElementRegistry.prototype = {
whenDefined
};
-function define(name, Class, options) {
+function CERDefine(name, Class, options) {
var
is = options && options[EXTENDS] || '',
CProto = Class.prototype,
@@ -832,7 +833,7 @@ function define(name, Class, options) {
name = name.toUpperCase();
constructors[name] = {
constructor: Class,
- create: is ? [is, name] : [name]
+ create: is ? [is, secondArgument(name)] : [name]
};
nodeNames.set(Class, name);
whenDefined(name);
@@ -921,7 +922,7 @@ function polyfillV1() {
var is = typeof options === 'string' ?
options : (options && options.is || '');
return is ?
- patchedCreateElement.call(this, name, is) :
+ patchedCreateElement.call(this, name, secondArgument(is)) :
patchedCreateElement.call(this, name);
});
}
@@ -945,3 +946,11 @@ try {
} catch(o_O) {
polyfillV1();
}
+
+try {
+ createElement.call(document, 'a', 'a');
+} catch(FireFox) {
+ secondArgument = function (is) {
+ return {is: is};
+ };
+}
View
@@ -1 +1 @@
-/*! (C) WebReflection Mit Style License */
+/*! (C) Andrea Giammarchi - @WebReflection - Mit Style License */
Oops, something went wrong.

0 comments on commit 0e98e64

Please sign in to comment.