Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Investigate why the Polymer minesweeper demo doesn't work in Firefox #203

Closed
Legioth opened this issue Mar 6, 2017 · 15 comments · Fixed by #205
Closed

Investigate why the Polymer minesweeper demo doesn't work in Firefox #203

Legioth opened this issue Mar 6, 2017 · 15 comments · Fixed by #205
Assignees
Milestone

Comments

@Legioth
Copy link
Member

Legioth commented Mar 6, 2017

Might also be broken in other non-Chrome browsers.

The Core Elements team might have experience with debugging similar issues.

@Legioth Legioth added the backlog label Mar 6, 2017
@Legioth
Copy link
Member Author

Legioth commented Mar 6, 2017

Might be enough to just make it use the v1 polyfill instead of v0.

@Legioth Legioth added ready and removed backlog labels Mar 6, 2017
@caalador
Copy link
Contributor

caalador commented Mar 7, 2017

The problem might also be that we might not wait for load of the webcomponents:

  • make sure the web components polyfill (webcomponents.js) is loaded first, certainly before any HTML imports, since this includes the polyfill for HTML imports.

@denis-anisimov
Copy link

Again: in EventHandler test (which is not yet merged) polyfill with correct version is added before anything as it should be. But it doesn't help.

@denis-anisimov denis-anisimov self-assigned this Mar 7, 2017
denis-anisimov pushed a commit that referenced this issue Mar 7, 2017
It doesn't fix #203 but at least this is necessary for it to work. Other
issues are most likely inside the HB itself.
@denis-anisimov
Copy link

denis-anisimov commented Mar 7, 2017

The demo requires correct polyfill version and it's set via #205.

It doesn't help as I mentioned before.
What I see for now:

  • polymer2 works fine without HB in FF.
  • Polymer component doesn't work being used inside HB regardless of the way of DOM manipulation (if element is created and added using console doesn't work either).
  • There is a difference between element without HB and inside HB: property $ is populated for working polymer element and it's null inside HB. This in its turn is a consequence of absence _template property for the created polymer element. This property exists for working polymer element and it's undefined for non-working element. Can be seen in console.

@denis-anisimov
Copy link

An addition: static template function returns undefined for the element inside HB and it returns template content for the regular polymer component.

@denis-anisimov
Copy link

dom-module.html has method register. This method is called for the regular polymer component before template()method (which tries to find a module by id via findModule function in the dom-module.html ). Inside HB template method is called before module registration happens and that's the reason why template()returns undefined.

@denis-anisimov
Copy link

I gave up. It requires more time than has been estimated.
What I see for now is the difference in the order of execution below.

HB:

  1. web-components -> something from client cache.js (GWT compiled HB stuff) -> PolymerElement.CTOR -> TemplateStamp -> finalizeClassAndSuper -> finalizeClass -> template -> import dom module -> find module.
  2. web components (some attribute changed callback)-> DomModule.attributeChangedCallback -> register

Regular Polymer :

  1. web-components -> HTMLImports.whenReady ->DomModule.attributeChangedCallback -> register
  2. web-components -> HTMLImports.whenReady -> PolymerElement.CTOR -> TemplateStamp -> finalizeClassAndSuper -> finalizeClass -> template -> import dom module -> find module.

@denis-anisimov denis-anisimov removed their assignment Mar 8, 2017
denis-anisimov pushed a commit that referenced this issue Mar 9, 2017
It doesn't fix #203 but at least this is necessary for it to work. Other
issues are most likely inside the HB itself.
@Legioth
Copy link
Member Author

Legioth commented Mar 10, 2017

Could try to see if this is somehow related to attributes being set only after some element has been attached to the DOM.

@Legioth Legioth self-assigned this Mar 10, 2017
Legioth pushed a commit that referenced this issue Mar 10, 2017
It doesn't fix #203 but at least this is necessary for it to work. Other
issues are most likely inside the HB itself.
It doesn't fix #203 but at least this is necessary for it to work. Other
issues are most likely inside the HB itself.
@Legioth Legioth reopened this Mar 10, 2017
@SomeoneToIgnore
Copy link
Contributor

During one way binding for Polymer feature implementation, I've found that adding defer attribute for webcomponents loaded in BootstrapHandler fixes issues for FF, although have tested it only on HB tests, not demos.

The downside of this approach is that Chrome starts to show errors in the console (but it works still).

@denis-anisimov
Copy link

FF also has an error in the console. Though it shows the content correctly and works.

@Legioth
Copy link
Member Author

Legioth commented Mar 17, 2017

One piece of the puzzle is the way minesweeper.html is imported. Removing the @HtmlImport annotation from the component and instead manually adding <link rel="import" href="minesweeper.html"> from the browser console after the page has been loaded results in a working mine sweeper.

@denis-anisimov
Copy link

And it one more argument in creating the "import" fully configured (with preset all the attributes).

@Legioth
Copy link
Member Author

Legioth commented Mar 17, 2017

This happens because we start using the web component from the load event of the html import element. Interactions between the polyfill and Polymer are also depending on the same event for setting up internal bookkeeping. This can be fixed by using HTMLImports.whenReady instead of the load event.

@denis-anisimov
Copy link

How does webcomponent differs here from any plain HTML element ?
What do you mean : "start using" ? Don't we add the element as a result of server->client RPC ?

Legioth added a commit to vaadin/flow that referenced this issue Mar 17, 2017
When using the v1 polyfills, Polymer depends on the load event for some
internal bookkeeping. This means that we cannot start using an imported
web component if our load listener is registered before Polymer's load
listener. Instead, we can use the HTMLImports.whenReady callback since
it's fired only after Polymer has had a chance to register everything.

Fixes vaadin/flow-demo#203
Legioth added a commit to vaadin/flow that referenced this issue Mar 20, 2017
When using the v1 polyfills, Polymer depends on the load event for some
internal bookkeeping. This means that we cannot start using an imported
web component if our load listener is registered before Polymer's load
listener. Instead, we can use the HTMLImports.whenReady callback since
it's fired only after Polymer has had a chance to register everything.

Fixes vaadin/flow-demo#203
Legioth added a commit to vaadin/flow that referenced this issue Mar 20, 2017
When using the v1 polyfills, Polymer depends on the load event for some
internal bookkeeping. This means that we cannot start using an imported
web component if our load listener is registered before Polymer's load
listener. Instead, we can use the HTMLImports.whenReady callback since
it's fired only after Polymer has had a chance to register everything.

Fixes vaadin/flow-demo#203
@Legioth
Copy link
Member Author

Legioth commented Mar 20, 2017

How does webcomponent differs here from any plain HTML element ?
What do you mean : "start using" ? Don't we add the element as a result of server->client RPC ?

The custom element registration has been performed when the load event is fired, but Polymer has not yet registered it because no attribute change event has been fired for the <dom-module> element. An element that is created after the tag has been registered as a custom element but before the corresponding <dom-module> has been picked up by Polymer will fail.

An element that was already in the DOM before the HTML import was loaded will be properly upgraded, as will an element that is added after HTMLImports.whenReady.

denis-anisimov pushed a commit to vaadin/flow that referenced this issue Mar 22, 2017
* Use HTMLImports.whenReady for detecting HTML import loading

When using the v1 polyfills, Polymer depends on the load event for some
internal bookkeeping. This means that we cannot start using an imported
web component if our load listener is registered before Polymer's load
listener. Instead, we can use the HTMLImports.whenReady callback since
it's fired only after Polymer has had a chance to register everything.

Fixes vaadin/flow-demo#203

* Merge branch 'master' into html_import_event

* Merge branch 'master' into html_import_event

* Merge master into html_import_event

* Merge branch 'master' into html_import_event
@SomeoneToIgnore SomeoneToIgnore modified the milestone: 0.0.21 Mar 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants