Closed mgibas closed 6 years ago
Just another temporary workaround until this change and #476 are resolved.
// TODO: Remove this once https://github.com/visionmedia/page.js/pull/475 is merged and deployed!
// Personally wouldn't throw this logic into production as it
// overrides the builtin path implementation in Chrome.
// However it's a decent workaround for development purposes.
// Throw this before any page.js logic is invoked.
Object.defineProperty(Event.prototype, 'path', {
get: function() {
var path = this.composedPath && this.composedPath() || [this.target];
var anchor = null;
for (var i = 0; i < path.length; i++) {
var element = path[i];
if (element.tagName === 'A' && element.href) {
anchor = element;
break;
}
}
return [anchor];
}
});
@matthewp - will this be considered for merge ? I would take care of code coverage then
Yep!
In shadow dom we can not traverse
path
usingparentNode
cause there can bedocument-element
in between other elements. Oncedocument-element
is found it will return fromonclick
(parentNode isundefined
) and reload the page.Why
path
array is build that way? No idea. Seems to be expected though causefor
loop is also used iniron-location
click handler - they should know a bit more about shadoDom :)https://github.com/PolymerElements/iron-location/blob/2486d275bef819aa3eedffee69158f695580d40f/iron-location.html#L342