-
Notifications
You must be signed in to change notification settings - Fork 255
Use DOM for marker content (allows listeners to work) #294
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ | |
| display: none; | ||
| } | ||
| </style> | ||
| <template><content></content></template> | ||
| <template><div><content></content></div></template> | ||
| </dom-module> | ||
|
|
||
| <script> | ||
|
|
@@ -366,8 +366,10 @@ | |
| subtree: true | ||
| }); | ||
|
|
||
| var content = this.innerHTML.trim(); | ||
| if (content) { | ||
| // Use this element's content DOM node for the info window content. | ||
| // Note that this will move the contents, not copy them. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really move, just preserve/reuse the existing DOM. |
||
| var content = this.children[0]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is selecting the first light dom child. are you meaning to pull the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I'm not the author of this pull request, just interested in getting the issue fixed) I've tried this line (369) with all four combinations of shady dom, shadow dom, webcomponents and webcomponents-lite and it certainly seems to work. Why might it fail under shadow dom? On the other hand, issues: The next line, More serious, Polymer ink bearing elements crash the infowindow. For example, when a paper-button or paper-icon-button is clicked inside the infowindow, elements are added inside the button to show the ink effect. This triggers
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to figure out why the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mlisook can you file a separate issue on the ink elements not working? That'll need investigation.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, right you are, Well I’m fairly certain the idea behind adding the The ink issue applies only to this pull request, not to the released code base, so I don’t think a new issue is appropriate. While it may be possible to loop through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No please, don't abandon it, it's working fine and we need actions from within the infowindow
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ebidel Sorry, I've been busy with other projects and haven't been able to get back to these until now. @mlisook is correct that the div was added so that you could depend on this.children[0] containing all of the contents. I can look into whether there's a way to make it work with just a text node and fix the @mlisook, Not sure I understand what your theory is on why the ink elements don't work in the InfoWindow. What's the fundamental problem you see with moving the DOM node? Is there another possible way to preserve the events handlers attached to the contents of the marker besides this idea? Realistically, the google-maps-marker element is radically less useful without this ability.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My original question of whether this will work under native shadow dom is still bothering me. One thing you could do is use (
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tst-dhudlow fundamentally, moving the DOM is absolutely the right thing to do. I also agree that preserving event handlers is vitally important. I don't really understand what's happening during the ripple/ink effect, but it's not (as I had thought) that the infowindow content is destroyed - it's still there, but the display of the content in the browser is gone (see pics). before clicking paper-icon-button +
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ebidel In my use case, I'm using I'm afraid I'm a bit fuzzy on the shadow dom / light dom distinction or what use cases the method I'm using breaks. |
||
| if (content && content.innerHTML.trim()) { | ||
| if (!this.info) { | ||
| // Create a new infowindow | ||
| this.info = new google.maps.InfoWindow(); | ||
|
|
@@ -381,7 +383,7 @@ | |
| } | ||
| this.info.setContent(content); | ||
| } else { | ||
| if (this.info) { | ||
| if (this.info && !this.open) { | ||
| // Destroy the existing infowindow. It doesn't make sense to have an empty one. | ||
| google.maps.event.removeListener(this.openInfoHandler_); | ||
| google.maps.event.removeListener(this.closeInfoHandler_); | ||
|
|
@@ -396,6 +398,9 @@ | |
| this.info.open(this.map, this.marker); | ||
| this.fire('google-map-marker-open'); | ||
| } else { | ||
| // When closing the info window, make sure the content is still available under this.content. | ||
| // This is necessary because we allow the info window to take the DOM node | ||
| this.content = this.info.getContent(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a comment why this is needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you use the DOM node instead of a copy of the HTML, the info window moves the node and is no longer under this element. When the InfoWindow is closed, you have to ensure that the contents are stored here, otherwise they're overwritten and lost whenever the InfoWindow is used to display some other marker's content.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a comment to the code if you think I'm still on the right track and this remains applicable.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sg. Please add the comment :) |
||
| this.info.close(); | ||
| this.fire('google-map-marker-close'); | ||
| } | ||
|
|
||


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.
element's content DOM -> element's light dom.
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.
I'd still like Line 41:
<template><div><content></content></div></template>changed.The idea is that users write:
But you already have a wrapper inside shadow dom. Can we remove the one in shadow dom and update the docs to explain to users that they need to use a single wrapper in their light dom. We'll also need to rev a minor version b/c this is a breaking change.
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.
I thought @mlisook had a solution that didn't require the user to wrap in a single element via
getContentChildNodes?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.
IIRC, it was traversing the existing DOM children.