Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/components/modebar/modebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ proto.update = function(graphInfo, buttons) {
}

if(fullLayout.modebar.orientation === 'v') {
this.element.prepend(logoGroup);
d3.select(this.element).insert(function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Does

d3.select(this.element).insert(logoGroup, ':first-child');

work also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that initially but it does not work:
screenshot_2019-01-28_17-07-49

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha right, does

d3.select(this.element).insert(d3.select(logoGroup), ':first-child');

work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d3.select(this.element).insert(d3.select(logoGroup), ':first-child');

Also fails with:
screenshot_2019-01-28_17-18-23

Would you prefer that I to turn the snippet from this PR into a one-liner?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Thanks for checking!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non- 🚫, but at that point the vanilla solution seems simpler:

pgNode.insertBefore(plotgroupBg.node(), pgNode.childNodes[0]);

newSvg.node().insertBefore(_glyphDefs.node().cloneNode(true),
newSvg.node().firstChild);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alexcjohnson! I agree it is simpler. Done in commit 4b164a2

Updated demo https://plnkr.co/edit/3Rfo4svtr6PUDCiCRM3l?p=preview

return logoGroup;
}, ':first-child');
} else {
this.element.appendChild(logoGroup);
}
Expand Down
12 changes: 12 additions & 0 deletions test/jasmine/assets/unpolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,17 @@
].join(' '));
}
});

Object.defineProperty(item, 'prepend', {
configurable: true,
enumerable: true,
writable: true,
value: function remove() {
throw Error([
'test/jasmine/assets/unpolyfill.js error: calling ChildNode.prepend()',
'which is not available in IE.'
].join(' '));
}
});
});
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);