Polymer / polymer-starter-kit

A starting point for Polymer apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 · 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

  1. sample code provided in tutorial should be correct and complete.
  2. if the window. before customElements.define(<mypagename>.is, <mypagename>) is actually needed for the page to work, then removing it should cause the same undefined error to happen again.

Actual outcome

  1. sample code is not correct and complete.
  2. window. before customElements.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.