Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.
Open
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 src/js/Properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ axs.properties.hasDirectTextDescendant = function(element) {
while (treeWalker.nextNode()) {
var resultElement = treeWalker.currentNode;
var parent = resultElement.parentNode;
// Handle elements hosted in <template>.content.
// Handle elements hosted in ShadowRoots.
parent = parent.host || parent;
var tagName = parent.tagName.toLowerCase();
var value = resultElement.nodeValue.trim();
Expand Down
13 changes: 8 additions & 5 deletions test/js/properties-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ test("Find text descendants in an iframe.", function() {
equal(axs.properties.hasDirectTextDescendant(foo), true);
});

test("Find text descendants in a <template>.", function() {
var templ = document.createElement('template');
templ.innerHTML = '<div>bar</div>';
// <template> might not be supported by the browser, test anyway.
var foo = (templ.content || templ).firstChild;
test("Find text descendants in a ShadowRoot.", function() {
var host = document.createElement('div');
if (host.attachShadow) {
host = host.attachShadow({mode: 'open'});
}
var foo = document.createElement('div');
foo.textContent = 'bar';
host.appendChild(foo);
equal(axs.properties.hasDirectTextDescendant(foo), true);
});

Expand Down