-
Notifications
You must be signed in to change notification settings - Fork 27
_mapApiLoaded called before object is fully initialized #16
Comments
@robdodson can you take a look? |
@rbjarnason how is your page setup? |
oh maybe this is the culprit: https://github.com/rbjarnason/your-priorities-app/blob/master/client_app/elements/yp-idea/yp-idea-cover-media.html#L62 Why do you need |
@robdodson I've done some more research into this and here is what I found so far. I had two levels of restamp in the yp-idea-cover-media element, I only needed the one at the top level. Here is what happens when I use restamp.
When I don't use restamp:
This probably has something to do with the inner dom-ifs and if="_withCoverMediaType()". But I don't understand why, I would have thought that when I add a new yp-idea-card (which holds yp-idea-cover-media) to the DOM it would be completely separate instance not reusing something from another instance of the element. Here is where I repeat over the yp-idea-cards to be displayed: In the meantime the _mapApiLoaded this.async hack seems to work nicely for me but would be good to understand why this isn't working as expected... |
@robdodson Another curious issue, while not strictly relevant to this repo, it might be connected. I have a dom-if with if="[[idea]]" and restamp, the same as above: Tonight I was adding a feature to set the zoom level on the map from the database, a location.map_zoom property on the idea object. After flipping between pages, I started to get Uncaught TypeError: Cannot read property 'location' of null errors and sometimes stack level too deep, when trying to read the zoom level from the idea object here: Somehow the top level dom-if with [[idea]] still, on reuse, never after a fresh page reload, result in the child elements having an idea object that is null. I would have thought by wrapping the whole thing in a dom-if I could always expect to have a valid idea object inside the dom-if. I got around this by adding more checks inside the dom-if if the idea object is really valid and everything works now... |
Hi all. |
Hi - this is quite old ;) but here is the file in question with the right path: https://github.com/CitizensFoundation/your-priorities-app/blob/master/client_app/src/yp-post/yp-post-cover-media.html |
When using google-streetview-pano with iron-pages, going between pages causes this element to fail as data bindings for this.panoId and this.position have not been initialized at the time of the _mapApiLoaded callback.
In the use below, it works fine the first time I load the page, but after using iron-pages to flip between pages a second load will trigger the _mapApiLoaded callback before the _getMapPosition has had a chance to set the this.position value.
This can be fixed by wrapping _mapApiLoaded contents in this.async but its a bit hacky as I don't understand why this is happening. What do you guys think?
The text was updated successfully, but these errors were encountered: