Skip to content

Commit

Permalink
Do not use /deep/ selector when using Polymer 1.x Shady DOM mode
Browse files Browse the repository at this point in the history
  • Loading branch information
s-kulikov committed Aug 25, 2016
1 parent 0cb9335 commit c6b2ab9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,15 @@
// it will scroll to the top of the page. let the browser finish the current event loop and scroll to the top of the page
// before we scroll to the element with id or name `middle`.
setTimeout(function() {
var hashElement = document.querySelector('html /deep/ ' + hash) || document.querySelector('html /deep/ [name="' + hash.substring(1) + '"]');
var hashElement;
try {
hashElement = document.querySelector('html /deep/ ' + hash) || document.querySelector('html /deep/ [name="' + hash.substring(1) + '"]');
} catch (e) {
// DOM exception 12 (unknown selector) is thrown in Safari when using Polymer 1.x Shady DOM mode
if (window.Polymer && window.Polymer.Settings && window.Polymer.Settings.dom === 'shady') {
hashElement = document.querySelector(hash) || document.querySelector('[name="' + hash.substring(1) + '"]');
}
}
if (hashElement && hashElement.scrollIntoView) {
hashElement.scrollIntoView(true);
}
Expand Down

0 comments on commit c6b2ab9

Please sign in to comment.