From ee65e68ca0e63862475234b3ca68a9b56e23f0ae Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Fri, 16 Oct 2015 14:20:41 -0700 Subject: [PATCH] Fix IE10 regressions. Fixes #2582 * Copy attribute list before modifying it * Fall back to document for current document if no currentScript --- src/lib/annotations/annotations.html | 7 +++++-- src/lib/dom-module.html | 2 +- test/unit/dom-module-inline.html | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/annotations/annotations.html b/src/lib/annotations/annotations.html index 8be5c62c4c..67db1f8ebc 100644 --- a/src/lib/annotations/annotations.html +++ b/src/lib/annotations/annotations.html @@ -267,7 +267,10 @@ // TODO(sjmiles): the distinction between an `annotation` and // `annotation data` is not as clear as it could be _parseNodeAttributeAnnotations: function(node, annotation) { - for (var i=node.attributes.length-1, a; (a=node.attributes[i]); i--) { + // Make copy of original attribute list, since the order may change + // as attributes are added and removed + var attrs = Array.prototype.slice.call(node.attributes); + for (var i=attrs.length-1, a; (a=attrs[i]); i--) { var n = a.name; var v = a.value; var b; @@ -304,7 +307,7 @@ // Initialize attribute bindings with any literal parts var literal = this._literalFromParts(parts); if (kind == 'attribute') { - node.setAttribute(name, literal); + node.setAttribute(name, literal); } // Clear attribute before removing, since IE won't allow removing // `value` attribute if it previously had a value (can't diff --git a/src/lib/dom-module.html b/src/lib/dom-module.html index 0d532565b6..36903984f2 100644 --- a/src/lib/dom-module.html +++ b/src/lib/dom-module.html @@ -100,7 +100,7 @@ function forceDocumentUpgrade() { if (cePolyfill) { var script = document._currentScript || document.currentScript; - var doc = script && script.ownerDocument; + var doc = script && script.ownerDocument || document; if (doc) { CustomElements.upgradeAll(doc); } diff --git a/test/unit/dom-module-inline.html b/test/unit/dom-module-inline.html index edc8cfc0d8..cfc8a76f6d 100644 --- a/test/unit/dom-module-inline.html +++ b/test/unit/dom-module-inline.html @@ -23,13 +23,14 @@ var module; suite('dom-module inline', function() { - var temp = document.getElementById('temp'); test('dom-module will work when inlined', function() { // simulate an inline dom-module // use a new script object to make document.currentScript work correctly var e = document.createElement('script'); - e.textContent = 'temp.innerHTML = \'\'; module = Polymer.DomModule.import("foo");'; + e.textContent = + 'temp.innerHTML = \'\';' + + 'module = Polymer.DomModule.import("foo");'; document.body.appendChild(e); assert.ok(module, 'found module'); });