-
Notifications
You must be signed in to change notification settings - Fork 365
Conversation
276c871
to
2db3a2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion but looks good.
src/js/Properties.js
Outdated
@@ -175,7 +175,8 @@ axs.properties.hasDirectTextDescendant = function(element) { | |||
while (treeWalker.nextNode()) { | |||
var resultElement = treeWalker.currentNode; | |||
var parent = resultElement.parentNode; | |||
var tagName = parent.tagName.toLowerCase(); | |||
// parent might not be an Element (e.g. DocumentFragment). | |||
var tagName = (parent.tagName || '').toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to just switch to parentElement on the previous line?
@alice I've realized the issue happens only if a node is hosted in a var frag = document.createDocumentFragment();
frag.appendChild(document.createElement('div'));
document.body.appendChild(frag); // the <div>.parentNode is <body>
var templ = document.createElement('template');
templ.content.appendChild(document.createElement('div'));
document.body.appendChild(templ); // the <div>.parentNode is <template>.content! I've updated the test and the implementation to handle specifically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix, LGTM 👍
LGTM2 |
Fixes #337.
@alice FYI