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

Commit

Permalink
Merge pull request #469 from arv/hidden-property
Browse files Browse the repository at this point in the history
Add support for reflecting the hidden attribute
  • Loading branch information
dfreedm committed Jul 16, 2014
2 parents db04e21 + 4e3bffa commit 67607e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/wrappers/HTMLElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@

var df = frag(contextElement, text);
contextElement.insertBefore(df, refNode);
},

get hidden() {
return this.hasAttribute('hidden');
},
set hidden(v) {
if (v) {
this.setAttribute('hidden', '');
} else {
this.removeAttribute('hidden');
}
}
});

Expand Down
9 changes: 9 additions & 0 deletions test/js/HTMLElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,13 @@ suite('HTMLElement', function() {
assert.equal(div.innerHTML, '<!--&\u00A0<>"-->');
});

test('hidden property', function() {
var div = document.createElement('div');
assert.isFalse(div.hidden);
div.hidden = true;
assert.isTrue(div.hasAttribute('hidden'));
assert.equal(div.getAttribute('hidden'), '');
div.hidden = false;
assert.isFalse(div.hasAttribute('hidden'));
});
});

0 comments on commit 67607e7

Please sign in to comment.