Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Walk attributes backward to avoid IE veto on removeAttribute. #1302

Merged
merged 1 commit into from
Mar 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,18 @@
// add annotation data from attributes to the `annotation` for node `node`
// TODO(sjmiles): the distinction between an `annotation` and
// `annotation data` is not as clear as it could be
// Walk attributes backwards, since removeAttribute can be vetoed by
// IE in certain cases (e.g. <input value="foo">), resulting in the
// attribute staying in the attributes list
_parseNodeAttributeAnnotations: function(node, annotation) {
for (var i=0, a; (a=node.attributes[i]); i++) {
for (var i=node.attributes.length-1, a; (a=node.attributes[i]); i--) {
var n = a.name, v = a.value;
// id
if (n === 'id') {
annotation.id = v;
}
// events (on-*)
else if (n.slice(0, 3) === 'on-') {
i--;
node.removeAttribute(n);
annotation.events.push({
name: n.slice(3),
Expand All @@ -187,7 +189,6 @@
else {
var b = this._parseNodeAttributeAnnotation(node, n, v);
if (b) {
i--;
annotation.bindings.push(b);
}
}
Expand Down