Skip to content
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

X-brower autonomous CEv1 #39

Merged
merged 6 commits into from
Dec 15, 2017
Merged

X-brower autonomous CEv1 #39

merged 6 commits into from
Dec 15, 2017

Conversation

tomalec
Copy link
Member

@tomalec tomalec commented Dec 13, 2017

Workaround imported scripts execution,
Starcounter/starcounter-include#69

⚠️ Change the expected behavior of dom-repeat and CE & scripts execution order
Due to HTML Imports v1 bug/inconsistency the order of onload callbacks (therefore stamping) of the same imported document (partial) is reversed (last to first)

  • Stop testing in IE due to html-imports issue
  • Start testing in Safari 10
  • Stop testing in Safari 9, as it's hard to investigate tests failures and I hope it's old enough to drop the support.

Copy link
Contributor

@alshakero alshakero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really love the recursive snippet, just minor comments from Skavsta-Stockholm bus 😄

replaceScripts(template.content);
});
};
replaceScripts(this.import);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a clean, super-readable snippet. Gotta compliment this.

README.md Outdated
@@ -125,11 +125,15 @@ Name | When | `event.detail`

Browser support relies mainly on polyfills support/spec compliance.

| Chrome | IE11 | Edge | Firefox | Safari 9 |
| Chrome | IE11 | Edge | Firefox | Safari 9+ |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 9+ includes 9? Because 18+ includes 18 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 forgot to push another README change

// https://github.com/webcomponents/html-imports/pull/77
// is merged
const HTMLImportsV1PolyfillInUse = HTMLImports && (HTMLImports.useNative === false) && HTMLImports.importForElement;
const scriptsSelector = 'script:not([type]),script[type="application/javascript"],script[type="text/javascript"]';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason not to include all script types. If you have a reason you can ignore my comment.

Copy link
Contributor

@warpech warpech Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. <script src="javascript.js"></script> is valid HTML5:

Omitting the attribute, or setting it to a JavaScript MIME type, means that the script is a classic script, to be interpreted according to the JavaScript Script top-level production.

https://www.w3.org/TR/html5/semantics-scripting.html#the-script-element

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@warpech yes this one in included. But this one is not <script type="application/json" />

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. To make it consistent with polyfill fix,
  2. <script type="application/json" /> is not executed as JS, so it's not blocked by browsers, there is no need to clone it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@warpech <script src="javascript.js"></script> is covered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right! Thanks for explanation

// Make scripts from imported templates work in browsers polyfilled by wcjs#v1 HTML Imports
if(HTMLImportsV1PolyfillInUse){
const replaceScripts = (content) => {
forEach(content.querySelectorAll('template'), template => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're using arrow functions (ES6), why not use native for...of? It iterates HTMLCollections and NodeLists and doesn't need hasOwnProperty,

Copy link
Contributor

@warpech warpech Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In response to @alshakero: It is a copy paste from webcomponents/html-imports#77 and as such it is better to keep it intact or change it at the source.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of laziness. To use the same snippet as in HTML Imports to make maintenance easier ;)

@tomalec
Copy link
Member Author

tomalec commented Dec 13, 2017

Is there anything left?

@@ -72,6 +89,24 @@
that.scopelessNodes = [];
that.clear();

// Make scripts from imported templates work in browsers polyfilled by wcjs#v1 HTML Imports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment saying that this should be revised after webcomponents/html-imports#77 is relesaed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I haven't noticed it. I would actually just move this comment to l. 92

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep them higher than lower? If you read it at l.17 and realize it's no longer needed, you will start to remove those bits. I've added duplicated comment to make it even more explicit.

// Make scripts from imported templates work in browsers polyfilled by wcjs#v1 HTML Imports
if(HTMLImportsV1PolyfillInUse){
const replaceScripts = (content) => {
forEach(content.querySelectorAll('template'), template => {
Copy link
Contributor

@warpech warpech Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In response to @alshakero: It is a copy paste from webcomponents/html-imports#77 and as such it is better to keep it intact or change it at the source.

@warpech
Copy link
Contributor

warpech commented Dec 13, 2017

Due to HTML Imports v1 bug/inconsistency the order of onload callbacks (therefore stamping) of the same imported document (partial) is reversed (last to first)

So the order is different in Chrome and in the polyfilled browsers?

It this problem fixable in the polyfilled? If yes, is there an issue for it?

@tomalec
Copy link
Member Author

tomalec commented Dec 13, 2017

So the order is different in Chrome and in the polyfilled browsers?

Yes

It this problem fixable in the polyfilled?

Hard to say right now.

If yes, is there an issue for it?

There is one mentioned in code comments and console.logs https://github.com/webcomponents/html-imports/issues/79

@@ -14,6 +14,23 @@

return (typeof HTMLImports !== 'undefined') && !HTMLImports.useNative && HTMLImports.parser && !isSafariWithWc;
})();
// We neet to workaround exectuting scripts from imported tempalte until
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> We need to workaround executing scripts from imported-template until

@tomalec
Copy link
Member Author

tomalec commented Dec 14, 2017

@warpech how about now?

Copy link
Contributor

@warpech warpech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@tomalec tomalec merged commit 9140137 into master Dec 15, 2017
@tomalec tomalec deleted the x-brower-autonomous-CEv1 branch December 15, 2017 14:09
@warpech
Copy link
Contributor

warpech commented Jan 9, 2018

Setting as “Finished” because it is:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants