Skip to content

Commit 7eb1f65

Browse files
committed
Clean up map-layer _registerMediaQuery
1 parent 8e4aa79 commit 7eb1f65

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/layer.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,9 @@ export class BaseLayerElement extends HTMLElement {
132132
}
133133
_registerMediaQuery(mq) {
134134
if (!this._changeHandler) {
135-
// Define and bind the change handler once
136135
this._changeHandler = () => {
137136
this._onRemove();
138137
if (this._mql.matches) {
139-
// TODO evaluate if _onAdd does the right thing for this situation
140138
this._onAdd();
141139
}
142140
// set the disabled 'read-only' attribute indirectly, via _validateDisabled
@@ -154,13 +152,11 @@ export class BaseLayerElement extends HTMLElement {
154152
this._mql.removeEventListener('change', this._changeHandler);
155153
}
156154

157-
// Set up the new media query and listener
158155
this._mql = map.matchMedia(mq);
159-
this._changeHandler(); // Initial evaluation
156+
this._changeHandler();
160157
this._mql.addEventListener('change', this._changeHandler);
161158
} else if (this._mql) {
162159
// the media attribute removed or query set to ''
163-
// Clean up the existing listener
164160
this._mql.removeEventListener('change', this._changeHandler);
165161
delete this._mql;
166162
// effectively, no / empty media attribute matches, do what changeHandler does

0 commit comments

Comments
 (0)