MCPcopy Index your code
hub / github.com/Maps4HTML/MapML.js / attributeChangedCallback

Method attributeChangedCallback

src/map-extent.js:145–234  ·  view source on GitHub ↗
(name, oldValue, newValue)

Source from the content-addressed store, hash-verified

143 return Util.getClosest(this, 'map-layer,layer-');
144 }
145 attributeChangedCallback(name, oldValue, newValue) {
146 if (this.#hasConnected /* jshint ignore:line */) {
147 switch (name) {
148 case 'units':
149 if (oldValue !== newValue) {
150 // handle side effects
151 }
152 break;
153 case 'label':
154 if (oldValue !== newValue) {
155 this._layerControlHTML.querySelector(
156 '.mapml-extent-item-name'
157 ).innerHTML = newValue || this.getMapEl().locale.dfExtent;
158 }
159 break;
160 case 'checked':
161 this.parentLayer
162 .whenReady()
163 .then(() => {
164 this._handleChange();
165 this._calculateBounds();
166 this._layerControlCheckbox.checked = newValue !== null;
167 })
168 .catch((error) => {
169 console.log(
170 'Error while waiting on parentLayer for map-extent checked callback: ' +
171 error
172 );
173 });
174 break;
175 case 'opacity':
176 if (oldValue !== newValue) {
177 this._opacity = newValue;
178 if (this._extentLayer) this._extentLayer.changeOpacity(newValue);
179 }
180 break;
181 case 'hidden':
182 if (oldValue !== newValue) {
183 this.parentLayer
184 .whenReady()
185 .then(() => {
186 let extentsRootFieldset =
187 this.parentLayer._propertiesGroupAnatomy;
188 let position = Array.from(
189 this.parentLayer.src
190 ? this.parentLayer.shadowRoot.querySelectorAll(
191 ':host > map-extent:not([hidden])'
192 )
193 : this.parentLayer.querySelectorAll(
194 ':scope > map-extent:not([hidden])'
195 )
196 ).indexOf(this);
197 if (newValue !== null) {
198 // remove from layer control (hide from user)
199 this._layerControlHTML.remove();
200 } else {
201 // insert the extent fieldset into the layer control container in
202 // the calculated position

Callers

nothing calls this directly

Calls 6

getMapElMethod · 0.95
_handleChangeMethod · 0.95
_calculateBoundsMethod · 0.95
removeMethod · 0.80
whenReadyMethod · 0.45

Tested by

no test coverage detected