Skip to content

Commit

Permalink
Update attribution_control.js (#8082)
Browse files Browse the repository at this point in the history
* Update attribution_control.js

fix #8047

Update attribution_control.js

optimalization of fix

* Update attribution_control.js

change variable names String -> HTML
fix linter errors

* fix line endings lint errors

* fix fix fix!

fix === linter error, remove unwanted flow monitoring added by linter fix
  • Loading branch information
poletani authored and mourner committed Mar 29, 2019
1 parent 840846f commit 79c3b98
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ui/control/attribution_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AttributionControl {
_container: HTMLElement;
_innerContainer: HTMLElement;
_editLink: ?HTMLAnchorElement;
_attribHTML: string;
styleId: string;
styleOwner: string;

Expand Down Expand Up @@ -157,8 +158,15 @@ class AttributionControl {
}
return true;
});

// check if attribution string is different to minimize DOM changes
const attribHTML = attributions.join(' | ');
if (attribHTML === this._attribHTML) return;

this._attribHTML = attribHTML;

if (attributions.length) {
this._innerContainer.innerHTML = attributions.join(' | ');
this._innerContainer.innerHTML = attribHTML;
this._container.classList.remove('mapboxgl-attrib-empty');
} else {
this._container.classList.add('mapboxgl-attrib-empty');
Expand Down

0 comments on commit 79c3b98

Please sign in to comment.