Skip to content

Commit

Permalink
Fix IE10 regressions. Fixes #2582
Browse files Browse the repository at this point in the history
* Copy attribute list before modifying it
* Fall back to document for current document if no currentScript
  • Loading branch information
kevinpschaaf committed Oct 16, 2015
1 parent e2d8446 commit ee65e68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dom-module.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions test/unit/dom-module-inline.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 = \'<dom-module id="foo"></dom-module>\'; module = Polymer.DomModule.import("foo");';
e.textContent =
'temp.innerHTML = \'<dom-module id="foo"></dom-module>\';' +
'module = Polymer.DomModule.import("foo");';
document.body.appendChild(e);
assert.ok(module, 'found module');
});
Expand Down

0 comments on commit ee65e68

Please sign in to comment.