@@ -12,61 +12,38 @@ export class HTMLTileElement extends HTMLElement {
1212 }
1313 /* jshint ignore:start */
1414 #hasConnected;
15+ #initialRow;
16+ #initialCol;
17+ #initialZoom;
1518 /* jshint ignore:end */
1619 get row ( ) {
17- return + ( this . hasAttribute ( 'row' ) ? this . getAttribute ( 'row' ) : 0 ) ;
20+ /* jshint ignore:start */
21+ return + this . #initialRow;
22+ /* jshint ignore:end */
1823 }
1924 set row ( val ) {
20- if ( this . #hasConnected) {
21- return ;
22- }
2325 var parsedVal = parseInt ( val , 10 ) ;
2426 if ( ! isNaN ( parsedVal ) ) {
2527 this . setAttribute ( 'row' , parsedVal ) ;
2628 }
2729 }
2830 get col ( ) {
29- return + ( this . hasAttribute ( 'col' ) ? this . getAttribute ( 'col' ) : 0 ) ;
31+ /* jshint ignore:start */
32+ return + this . #initialCol;
33+ /* jshint ignore:end */
3034 }
3135 set col ( val ) {
32- if ( this . #hasConnected) {
33- return ;
34- }
3536 var parsedVal = parseInt ( val , 10 ) ;
3637 if ( ! isNaN ( parsedVal ) ) {
3738 this . setAttribute ( 'col' , parsedVal ) ;
3839 }
3940 }
4041 get zoom ( ) {
41- // for templated or queried features ** native zoom is only used for zoomTo() **
42- let meta = { } ,
43- metaEl = this . getMeta ( 'zoom' ) ;
44- if ( metaEl )
45- meta = Util . _metaContentToObject ( metaEl . getAttribute ( 'content' ) ) ;
46- if ( this . _parentElement . nodeName === 'MAP-LINK' ) {
47- // nativeZoom = zoom attribute || (sd.map-meta zoom 'value' || 'max') || this._initialZoom
48- return + ( this . hasAttribute ( 'zoom' )
49- ? this . getAttribute ( 'zoom' )
50- : meta . value
51- ? meta . value
52- : meta . max
53- ? meta . max
54- : this . _initialZoom ) ;
55- } else {
56- // for "static" features
57- // nativeZoom zoom attribute || this._initialZoom
58- // NOTE we don't use map-meta here, because the map-meta is the minimum
59- // zoom bounds for the layer, and is extended by additional features
60- // if added / removed during layer lifetime
61- return + ( this . hasAttribute ( 'zoom' )
62- ? this . getAttribute ( 'zoom' )
63- : this . _initialZoom ) ;
64- }
42+ /* jshint ignore:start */
43+ return this . #initialZoom;
44+ /* jshint ignore:end */
6545 }
6646 set zoom ( val ) {
67- if ( this . #hasConnected) {
68- return ;
69- }
7047 var parsedVal = parseInt ( val , 10 ) ;
7148 if ( ! isNaN ( parsedVal ) && parsedVal >= 0 && parsedVal <= 25 ) {
7249 this . setAttribute ( 'zoom' , parsedVal ) ;
@@ -93,18 +70,47 @@ export class HTMLTileElement extends HTMLElement {
9370 // Always call super first in constructor
9471 super ( ) ;
9572 }
73+ getAttribute ( name ) {
74+ if ( this . #hasConnected /* jshint ignore:line */ ) {
75+ switch ( name ) {
76+ case 'row' :
77+ return String ( this . #initialRow) ; /* jshint ignore:line */
78+ break ;
79+ case 'col' :
80+ return String ( this . #initialCol) ; /* jshint ignore:line */
81+ break ;
82+ case 'zoom' :
83+ return String ( this . #initialZoom) ; /* jshint ignore:line */
84+ break ;
85+ }
86+ }
87+ return super . getAttribute ( name ) ;
88+ }
89+ setAttribute ( name , value ) {
90+ if ( this . #hasConnected /* jshint ignore:line */ ) {
91+ switch ( name ) {
92+ case 'row' :
93+ case 'col' :
94+ case 'zoom' :
95+ return ;
96+ }
97+ }
98+ super . setAttribute ( name , value ) ;
99+ }
96100 async connectedCallback ( ) {
97101 // initialization is done in connectedCallback, attribute initialization
98102 // calls (which happen first) are effectively ignored, so we should be able
99103 // to rely on them being all correctly set by this time e.g. zoom, row, col
100104 // all now have a value that together identify this tiled bit of space
105+ // row,col,zoom can't / shouldn't change
101106 /* jshint ignore:start */
107+ this . #initialZoom = this . hasAttribute ( 'zoom' )
108+ ? + this . getAttribute ( 'zoom' )
109+ : this . getMapEl ( ) . zoom ;
110+ this . #initialRow = this . hasAttribute ( 'row' ) ? + this . getAttribute ( 'row' ) : 0 ;
111+ this . #initialCol = this . hasAttribute ( 'col' ) ? + this . getAttribute ( 'col' ) : 0 ;
102112 this . #hasConnected = true ;
103113 /* jshint ignore:end */
104- // set the initial zoom of the map when features connected
105- // used for fallback zoom getter for static features
106- // ~copied from map-feature.js
107- this . _initialZoom = this . getMapEl ( ) . zoom ;
108114 // Get parent element to determine how to handle the tile
109115 // Need to handle shadow DOM correctly like map-feature does
110116 this . _parentElement =
@@ -182,11 +188,6 @@ export class HTMLTileElement extends HTMLElement {
182188 case 'row' :
183189 case 'col' :
184190 case 'zoom' :
185- // Prevent changes to row, col, and zoom after initialization
186- if ( oldValue !== newValue ) {
187- this . setAttribute ( name , oldValue ) ;
188- return ;
189- }
190191 break ;
191192 case 'src' :
192193 if ( oldValue !== newValue ) {
0 commit comments