From 44cf5b68119e64f05888374f532a950191c85a27 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 16 Jul 2015 12:46:00 -0700 Subject: [PATCH 01/10] Fix #351: an element upgrades first via its tag name and only secondarily by its is attribute. --- src/CustomElements/upgrade.js | 12 ++++++++---- tests/CustomElements/js/upgrade.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/CustomElements/upgrade.js b/src/CustomElements/upgrade.js index 92a3f95..2d5c93a 100644 --- a/src/CustomElements/upgrade.js +++ b/src/CustomElements/upgrade.js @@ -35,11 +35,15 @@ var flags = scope.flags; function upgrade(node, isAttached) { if (!node.__upgraded__ && (node.nodeType === Node.ELEMENT_NODE)) { var is = node.getAttribute('is'); - var definition = scope.getRegisteredDefinition(is || node.localName); + // find definition first by localName and secondarily by is attribute + var definition = scope.getRegisteredDefinition(node.localName) || + scope.getRegisteredDefinition(is); if (definition) { - if (is && definition.tag == node.localName) { - return upgradeWithDefinition(node, definition, isAttached); - } else if (!is && !definition.extends) { + // upgrade with is iff the definition tag matches the element tag + // and don't upgrade if there's an is and the definition does not extend + // a native element + if ((is && definition.tag == node.localName) || + (!is && !definition.extends)) { return upgradeWithDefinition(node, definition, isAttached); } } diff --git a/tests/CustomElements/js/upgrade.js b/tests/CustomElements/js/upgrade.js index cbc1a6c..f813fd1 100644 --- a/tests/CustomElements/js/upgrade.js +++ b/tests/CustomElements/js/upgrade.js @@ -118,4 +118,16 @@ suite('upgradeElements', function() { }); }); + test('CustomElements.upgrade upgrades element syntax and ignores bogus type extension', function() { + var XProto = Object.create(HTMLElement.prototype); + XProto.test = 'x-test-value'; + document.registerElement('x-test', { + prototype: XProto + }); + work.innerHTML = ''; + CustomElements.upgradeAll(work); + var x = work.querySelector('x-test'); + assert.equal(x.test, 'x-test-value'); + }); + }); From bc382cfc54da393fe86b121dbe816b03a98c9208 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 23 Jul 2015 19:27:02 -0700 Subject: [PATCH 02/10] Fixes #355 install `innerHTML` on Template elements. --- src/Template/Template.js | 24 ++++++++++++++++++++++++ tests/Template/html/Template.html | 13 +++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/Template/Template.js b/src/Template/Template.js index f8d254c..1f9ed4b 100644 --- a/src/Template/Template.js +++ b/src/Template/Template.js @@ -14,6 +14,8 @@ if (typeof HTMLTemplateElement === 'undefined') { var TEMPLATE_TAG = 'template'; + var contentDoc = document.implementation.createHTMLDocument('template'); + /** Provides a minimal shim for the