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

Commit 67607e7

Browse files
committed
Merge pull request #469 from arv/hidden-property
Add support for reflecting the hidden attribute
2 parents db04e21 + 4e3bffa commit 67607e7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/wrappers/HTMLElement.js

+11
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@
230230

231231
var df = frag(contextElement, text);
232232
contextElement.insertBefore(df, refNode);
233+
},
234+
235+
get hidden() {
236+
return this.hasAttribute('hidden');
237+
},
238+
set hidden(v) {
239+
if (v) {
240+
this.setAttribute('hidden', '');
241+
} else {
242+
this.removeAttribute('hidden');
243+
}
233244
}
234245
});
235246

test/js/HTMLElement.js

+9
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,13 @@ suite('HTMLElement', function() {
101101
assert.equal(div.innerHTML, '<!--&\u00A0<>"-->');
102102
});
103103

104+
test('hidden property', function() {
105+
var div = document.createElement('div');
106+
assert.isFalse(div.hidden);
107+
div.hidden = true;
108+
assert.isTrue(div.hasAttribute('hidden'));
109+
assert.equal(div.getAttribute('hidden'), '');
110+
div.hidden = false;
111+
assert.isFalse(div.hasAttribute('hidden'));
112+
});
104113
});

0 commit comments

Comments
 (0)