Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doc-amd",
"version": "1.3.0",
"version": "1.3.1",
"homepage": "https://github.com/elo7/doc-amd",
"description": "A small DOM manipulation library",
"main": "doc.js",
Expand Down
5 changes: 4 additions & 1 deletion doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ define('doc', ['event'], function(event) {

var search = function(namespace, selector) {
var selector = selector.replace(/^\s+|\s+$/g, '');
if (matcher.isTag(selector)) {
if (matcher.isTag(selector) && namespace.getElementsByTagName) {
return convertHtmlCollectionToArray(namespace.getElementsByTagName(selector));
} else if(matcher.isId(selector)) {
selector = selector.replace('#', '');
if (namespace.getElementById) {
return namespace.getElementById(selector);
}
return document.getElementById(selector);
} else if (matcher.isClass(selector) && namespace.getElementsByClassName) {
selector = selector.replace('.', '');
Expand Down
2 changes: 1 addition & 1 deletion doc.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elo7-doc-amd",
"version": "1.3.0",
"version": "1.3.1",
"license": "BSD-3-Clause",
"description": "Elo7 doc amd",
"keywords": [
Expand All @@ -19,16 +19,16 @@
},
"author": "Elo7",
"dependencies": {
"define-async": "1.1.1",
"define-async": "1.2.0",
"elo7-events-amd": "1.1.3"
},
"devDependencies": {
"bower": "1.4.1",
"http-server": "0.7.4",
"mocha": "2.0.1",
"bower": "1.8.2",
"http-server": "0.10.0",
"mocha": "4.0.1",
"mocha-phantomjs": "4.1.0",
"phantomjs-prebuilt": "2.1.14",
"proclaim": "2.0.0",
"uglify-js": "3.0.28"
"phantomjs-prebuilt": "2.1.15",
"proclaim": "3.4.6",
"uglify-js": "3.1.3"
}
}
28 changes: 28 additions & 0 deletions test/docTest.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<div id='first-broadcast-listener'></div>
<div id='second-broadcast-listener'></div>
<div id='third-broadcast-listener'></div>
<div id='shadow-root-test'></div>
</div>

<div id="mocha"></div>
Expand Down Expand Up @@ -632,6 +633,33 @@
}, 10);
fireEvent($('#debounce-button').first(), 'click');
});
describe('with shadow DOM', function() {
before(function() {
if (!HTMLElement.prototype.createShadowRoot) {
this.skip();
}
});
it("should find elements inside shadow root by tag name", function() {
var $root = $($('#shadow-root-test').first().createShadowRoot()),
div = document.createElement('div');
$root.append(div);
assert.equal($root.find('div').first(), div);
});
it("should find elements inside shadow root by id", function() {
var $root = $($('#shadow-root-test').first().createShadowRoot()),
div = document.createElement('div');
div.id = 'mocha';
$root.append(div);
assert.equal($root.find('#mocha').first(), div);
});
it("should find elements inside shadow root by class name", function() {
var $root = $($('#shadow-root-test').first().createShadowRoot()),
div = document.createElement('div');
div.className = 'search-class-test';
$root.append(div);
assert.equal($root.find('.search-class-test').first(), div);
});
});
});
});
</script>
Expand Down