Permalink
Browse files

Implement ShadowRoot getElementById

This is implemented using querySelector.

Fixes #130
  • Loading branch information...
arv committed Apr 29, 2013
1 parent 19c596f commit 1bc20a60860b816e070feac44863053a2c6acb9b
Showing with 15 additions and 0 deletions.
  1. +4 −0 src/wrappers/ShadowRoot.js
  2. +11 −0 test/js/ShadowRoot.js
@@ -44,6 +44,10 @@
elementFromPoint: function(x, y) {
return elementFromPoint(this, this.ownerDocument, x, y);
+ },
+
+ getElementById: function(id) {
+ return this.querySelector('#' + id);
}
});
View
@@ -26,4 +26,15 @@ suite('ShadowRoot', function() {
assert.equal(sr.elementFromPoint(5, 5), a);
});
+ test('getElementById', function() {
+ var div = document.createElement('div');
+ var sr = div.createShadowRoot();
+ sr.innerHTML = '<a id=a name=b></a><b id=b></b>';
+ var a = sr.firstChild;
+ var b = sr.lastChild;
+
+ assert.equal(sr.getElementById('a'), a);
+ assert.equal(sr.getElementById('b'), b);
+ });
+
});

0 comments on commit 1bc20a6

Please sign in to comment.