Is the `window.` before `customElement.define()` needed or not? https://www.polymer-project.org/2.0/start/toolbox/create-a-page
ShimomiAizo opened this issue · 1 comments
Description
https://www.polymer-project.org/2.0/start/toolbox/create-a-page
I followed the instruction in this tutorial and copied the codes in the Create an element for the new page section, but error returned in console saying my new page is not defined. I asked someone and he suggested adding window.
before customElements.define(<mypagename>.is, <mypagename>)
, but window.
is not included in the sample code provided in the Create an element for the new page section. After adding window.
before customElements.define(<mypagename>.is, <mypagename>)
my new page worked fine, but as I deleted the window.
to try to replicate the error for writing this issue, I noticed that the page works fine even though the window.
is not there anymore.
Expected outcome
- sample code provided in tutorial should be correct and complete.
- if the
window.
beforecustomElements.define(<mypagename>.is, <mypagename>)
is actually needed for the page to work, then removing it should cause the sameundefined
error to happen again.
Actual outcome
- sample code is not correct and complete.
window.
beforecustomElements.define(<mypagename>.is, <mypagename>)
has been deleted but the page is still working.
Live Demo
Steps to reproduce
Browsers Affected
- Chrome
- Edge
- Firefox
- IE 11
- Safari 8
- Safari 9
window.
isn't necessarily required because customElements
is in the global namespace - see https://stackoverflow.com/questions/11148997/window-variablename for more information about globals.