Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
refune attribute serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Apr 2, 2014
1 parent 1b675dd commit d1bbb25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
18 changes: 0 additions & 18 deletions binding.js

This file was deleted.

10 changes: 8 additions & 2 deletions x-dom-serializer.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script>
Polymer('x-serializer', {
tab: ' ',
attributesBlacklist: ['style', 'tabindex', 'role'],
dumpTag: function(node, indent) {
if (node.dumpTag) {
return node.dumpTag(this.dumpTab, indent, this.tab);
Expand All @@ -23,7 +24,8 @@
Object.keys(attributes).forEach(function(k) {
var v = attributes[k];
if (v !== null && v !== undefined) {
html += ' ' + k + (v !== '' ? '="' + v + '"': '');
var sep = typeof v === 'string' && v.indexOf('"') >= 0 ? '\'' : '"';
html += ' ' + k + (v !== '' ? '=' + sep + v + sep: '');
}
})
html += '>';
Expand Down Expand Up @@ -79,7 +81,11 @@
},
// special handling for certain attributes: style, class
filterAttributes: function(attributes) {
attributes.style = null;
for (var i in attributes) {
if (this.attributesBlacklist.indexOf(i) >= 0 || i.match(/^aria/)) {
attributes[i] = null;
}
}
var v = attributes['class'];
v = v ? v.replace(/selected-element/g, '') : null;
if (v && (v.trim() == 'selected')) {
Expand Down

0 comments on commit d1bbb25

Please sign in to comment.