-
Notifications
You must be signed in to change notification settings - Fork 5
Fix change options attribute handling #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix change options attribute handling #62
Conversation
src/l-tile-layer-wms.js
Outdated
| this.reloadLayer(); | ||
| } | ||
| if (name === "options" && oldValue !== newValue && this.layer) { | ||
| this.layer.setParams(newValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should newValue parsed with JSON.parse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup! only noticed it when, while testing options attribute mutations in the app, the WMS requests being made were a little off :P (it's the first force push... bad habit I know)
d4e855e to
6814fc7
Compare
6814fc7 to
0ed3cfd
Compare
src/l-tile-layer-wms.js
Outdated
| }); | ||
|
|
||
| const standardOptions = parse(schema, this); | ||
| const nonStandardOptionsElement = this.getAttribute("options"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonStandardOptionsElement feels like the wrong variable name, something like text or attr may be better suffixes
src/l-tile-layer-wms.js
Outdated
| reloadLayer() { | ||
| if (this.layer) { | ||
| this.layer.remove(); | ||
| _parseNonStandardOptions(nonStandardOptionsElement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter to this function is either string or null. Perhaps optionsText would be a better variable name. Not perfect, but better :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or keep it as an Element and move the .getAttribute("options") call inside it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even, since it's a private method and the only positional argument is this, remove the positional argument altogether.
// E.g. calling code
let opts = this._parseNonStandardOptions()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, I forget how functions bind parent caller objects in JS ;-)
The this pointer is a mysterious mechanism. Although, probably ok in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Or keep it as an Element and move the .getAttribute("options") call inside it." I don't need getAttribute in the change callback that also uses the method, that's why I left it out
andrewgryan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to fix the double-map lifecycle issue and adds observed attrs. Good work!
This PR is meant to fix the reload tile layer wms bug and add support for tile layer wms standard attribute changes (grid options not included).