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

Method _runMutationObserver

src/layer.js:492–559  ·  view source on GitHub ↗
(elementsGroup)

Source from the content-addressed store, hash-verified

490 * child element processing.
491 */
492 _runMutationObserver(elementsGroup) {
493 const _addStylesheetLink = (mapLink) => {
494 this.whenReady().then(() => {
495 this._layer.renderStyles(mapLink);
496 });
497 };
498 const _addStyleElement = (mapStyle) => {
499 this.whenReady().then(() => {
500 this._layer.renderStyles(mapStyle);
501 });
502 };
503 const _addExtentElement = (mapExtent) => {
504 this.whenReady().then(() => {
505 delete this._layer.bounds;
506 this._validateDisabled();
507 });
508 };
509 // is this really necessary? Do we believe that remote mapml documents will
510 // be interactive i.e. script access to their DOM?
511 let root = this.src ? this.shadowRoot : this,
512 pseudo = root instanceof ShadowRoot ? ':host' : ':scope';
513 const _addMetaElement = (mapMeta) => {
514 this.whenReady().then(() => {
515 this._layer._calculateBounds();
516 this._validateDisabled();
517 });
518 };
519 for (let i = 0; i < elementsGroup.length; ++i) {
520 let element = elementsGroup[i];
521 switch (element.nodeName) {
522 case 'MAP-LINK':
523 if (element.link && !element.link.isConnected)
524 _addStylesheetLink(element);
525 break;
526 case 'MAP-STYLE':
527 if (element.styleElement && !element.styleElement.isConnected) {
528 _addStyleElement(element);
529 }
530 break;
531 case 'MAP-EXTENT':
532 _addExtentElement(element);
533 break;
534 case 'MAP-META':
535 // to consider: should we only honour the first child map-meta of a
536 // given name value? i.e. run _addMetaElement only for
537 // this.querySelector('map-meta[name=zoom]')
538 // tbd will this do it: element === this.querySelector(`[name=${element.getAttribute('name')}]`)
539 // a no, it will need to take into account src/shadowDom
540 const name =
541 element.hasAttribute('name') &&
542 (element.getAttribute('name').toLowerCase() === 'zoom' ||
543 element.getAttribute('name').toLowerCase() === 'extent');
544 if (
545 name &&
546 element ===
547 root.querySelector(
548 `${pseudo} > [name=${element.getAttribute('name')}]`
549 ) &&

Callers 2

_onAddMethod · 0.95
_bindMutationObserverMethod · 0.95

Calls 1

getAttributeMethod · 0.80

Tested by

no test coverage detected