Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM Inspector: Fallback to .childNodes when .children not present #2242

Merged
merged 1 commit into from
Feb 28, 2017
Merged
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
14 changes: 13 additions & 1 deletion src/js/scriptlets/dom-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,17 @@ var elementsFromSpecialSelector = function(selector) {

/******************************************************************************/

var getSvgRootChildren = function() {
if ( svgRoot.children ) {
return svgRoot.children;
} else {
var childNodes = Array.prototype.slice.apply(svgRoot.childNodes);
return childNodes.filter(function(node) {
return node.nodeType === Node.ELEMENT_NODE;
});
}
};

var highlightElements = function(scrollTo) {
var wv = pickerRoot.contentWindow.innerWidth;
var hv = pickerRoot.contentWindow.innerHeight;
Expand All @@ -842,6 +853,7 @@ var highlightElements = function(scrollTo) {
var xl, xr, yt, yb, w, h, ws;
var xlu = Number.MAX_VALUE, xru = 0, ytu = Number.MAX_VALUE, ybu = 0;
var lists = highlightedElementLists;
var svgRootChildren = getSvgRootChildren();

for ( var i = 0; i < lists.length; i++ ) {
elems = lists[i];
Expand Down Expand Up @@ -881,7 +893,7 @@ var highlightElements = function(scrollTo) {
if ( yt < ytu ) { ytu = yt; }
if ( yb > ybu ) { ybu = yb; }
}
svgRoot.children[i+1].setAttribute('d', islands.join('') || 'M0 0');
svgRootChildren[i+1].setAttribute('d', islands.join('') || 'M0 0');
}

svgRoot.firstElementChild.setAttribute('d', ocean.join(''));
Expand Down