forked from leaflet-extras/leaflet-map
-
Notifications
You must be signed in to change notification settings - Fork 4
/
leaflet-popup.html
34 lines (29 loc) · 914 Bytes
/
leaflet-popup.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<script>
'use strict';
window.leafletMap = window.leafletMap || {};
window.leafletMap.Mixins = window.leafletMap.Mixins || {};
leafletMap.Mixins.LeafletPopupContent = Polymer.dedupingMixin((baseClass) => class extends baseClass {
connectedCallback() {
if (MutationObserver && !this.observer_) {
this.observer_ = new MutationObserver(this.updatePopupContent.bind(this));
this.observer_.observe(this, { childList: true, characterData: true, attributes: true, subtree: true });
}
}
updatePopupContent() {
if (!this.feature) {
return;
}
this.feature.unbindPopup();
// TODO: Hack, ignore <leaflet-point>-tag
var content = Polymer.dom(this).innerHTML.replace(/<\/?leaflet-point[^>]*>/g, '').trim();
if (content) {
this.feature.bindPopup(content);
}
}
disconnectedCallback() {
if (this.observer_) {
this.observer_.disconnect();
}
}
});
</script>