-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
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.
I really love the recursive snippet, just minor comments from Skavsta-Stockholm bus 😄
replaceScripts(template.content); | ||
}); | ||
}; | ||
replaceScripts(this.import); |
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.
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+ | |
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.
I think 9+ includes 9? Because 18+ includes 18 😄
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.
👍 forgot to push another README change
imported-template.html
Outdated
// 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"]'; |
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.
I don't see a reason not to include all script
types. If you have a reason you can ignore my 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.
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
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.
@warpech yes this one in included. But this one is not <script type="application/json" />
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.
- To make it consistent with polyfill fix,
<script type="application/json" />
is not executed as JS, so it's not blocked by browsers, there is no need to clone 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.
@warpech <script src="javascript.js"></script>
is covered.
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.
Ah right! Thanks for explanation
imported-template.html
Outdated
// Make scripts from imported templates work in browsers polyfilled by wcjs#v1 HTML Imports | ||
if(HTMLImportsV1PolyfillInUse){ | ||
const replaceScripts = (content) => { | ||
forEach(content.querySelectorAll('template'), template => { |
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.
Since you're using arrow functions (ES6), why not use native for...of
? It iterates HTMLCollections and NodeLists and doesn't need hasOwnProperty
,
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.
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.
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.
Out of laziness. To use the same snippet as in HTML Imports to make maintenance easier ;)
Is there anything left? |
imported-template.html
Outdated
@@ -72,6 +89,24 @@ | |||
that.scopelessNodes = []; | |||
that.clear(); | |||
|
|||
// Make scripts from imported templates work in browsers polyfilled by wcjs#v1 HTML Imports |
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.
Please add a comment saying that this should be revised after webcomponents/html-imports#77 is relesaed.
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.
Like one at https://github.com/Juicy/imported-template/pull/39/files/cf2267548157b82b9797fca37bd9cbe104362e8e#diff-5df4cf8262d2c40490e3787fbc31c2abR17 ?
Would you like to see a duplicate comment here as well?
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.
Oh, I haven't noticed it. I would actually just move this comment to l. 92
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.
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.
imported-template.html
Outdated
// Make scripts from imported templates work in browsers polyfilled by wcjs#v1 HTML Imports | ||
if(HTMLImportsV1PolyfillInUse){ | ||
const replaceScripts = (content) => { | ||
forEach(content.querySelectorAll('template'), template => { |
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.
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.
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? |
Yes
Hard to say right now.
There is one mentioned in code comments and console.logs https://github.com/webcomponents/html-imports/issues/79 |
imported-template.html
Outdated
@@ -14,6 +14,23 @@ | |||
|
|||
return (typeof HTMLImports !== 'undefined') && !HTMLImports.useNative && HTMLImports.parser && !isSafariWithWc; | |||
})(); | |||
// We neet to workaround exectuting scripts from imported tempalte until |
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.
-> We need to workaround executing scripts from imported-template until
@warpech how about now? |
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.
Lgtm
Setting as “Finished” because it is:
|
Workaround imported scripts execution,
Starcounter/starcounter-include#69
dom-repeat
and CE & scripts execution orderDue to HTML Imports v1 bug/inconsistency the order of onload callbacks (therefore stamping) of the same imported document (partial) is reversed (last to first)