Skip to content

Commit

Permalink
Use Map's forEach instead of iterating over values() / keys() to supp…
Browse files Browse the repository at this point in the history
…ort IE11
  • Loading branch information
bedeoverend committed Apr 30, 2017
1 parent d473562 commit cc1a88a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class CustomAttributeRegistry {
document = document || this.ownerDocument;

var matches = document.querySelectorAll("[" + attrName + "]");

// Use a forEach as Edge doesn't support for...of on a NodeList
forEach.call(matches, function(match) {
this._found(attrName, match);
}, this);
Expand All @@ -79,20 +81,20 @@ class CustomAttributeRegistry {
}
}, this);

for(var attr of this._attrMap.keys()) {
this._attrMap.forEach(function(constructor, attr) {
this._upgradeAttr(attr, element);
}
}, this);
}

_downgrade(element) {
var map = this._elementMap.get(element);
if(!map) return;

for(var inst of map.values()) {
if(inst.disconnectedCallback) {
map.forEach(function(inst) {
if (inst.disconnectedCallback) {
inst.disconnectedCallback();
}
}
}, this);

this._elementMap.delete(element);
}
Expand Down
10 changes: 5 additions & 5 deletions registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ class CustomAttributeRegistry {
}
}, this);

for(var attr of this._attrMap.keys()) {
this._attrMap.forEach(function(constructor, attr) {
this._upgradeAttr(attr, element);
}
}, this);
}

_downgrade(element) {
var map = this._elementMap.get(element);
if(!map) return;

for(var inst of map.values()) {
if(inst.disconnectedCallback) {
map.forEach(function(inst) {
if (inst.disconnectedCallback) {
inst.disconnectedCallback();
}
}
}, this);

this._elementMap.delete(element);
}
Expand Down

0 comments on commit cc1a88a

Please sign in to comment.