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

⚠️ 📖 DRAFT: <include- src={uri}> Client Side Include #109

Closed
wants to merge 19 commits into from

Conversation

brandondees
Copy link
Collaborator

@brandondees brandondees commented Jul 15, 2017

there are some major limitations for now
namely included scripts do not run
and nested linked stylesheets are not loaded
but images and inline styles do work
which makes this useful enough for some common cases

I'd like to do some homework to round up other folks' existing examples of how to approach this functionality. Ideally this can become easy enough and useful enough that it can gain some traction in terms of actual usage and lead to the standards groups accepting the idea as worth specifying as a platform feature. Part of the ideal is that html includes (inlining remote partials, not imports) should work without any JS and without need for any server side render code or build-time operations. HTML authors can simply re-use partials across pages by including them with a tag.

Related Internally

Related Externally

Current Implementions

@brandondees brandondees self-assigned this Jul 15, 2017
@brandondees brandondees requested a review from snuggs July 15, 2017 22:48
@brandondees
Copy link
Collaborator Author

I'm open to discussion about whether it is important to support included linked stylesheets, as well as included scripts. I'm not sure what other potential caveats this functionality might have, so feedback and suggestions are welcome.

@snuggs
Copy link
Member

snuggs commented Jul 16, 2017

OH WOWW

@snuggs snuggs changed the title initial proof of concept includes <include-html src={uri}> Proposal Jul 16, 2017
@snuggs snuggs changed the title <include-html src={uri}> Proposal <include-html src={uri}> HTML Client Side Include Jul 16, 2017
@snuggs
Copy link
Member

snuggs commented Jul 16, 2017

@brandondees 🙏 Super proud of you on this attempt. We've got a long way to go but looking forward to this journey. Because...The web has been waiting for this since PHP and we finally can make a difference in contribution. /cc @pachonk @robcole @Robertchristopher @mrbernnz @btakita @dcchuck @janz93

@snuggs
Copy link
Member

snuggs commented Jul 16, 2017

@brandondees updated with references as per your request. We are already wrangling some in #71 capture d ecran 2017-07-16 a 06 06 50

@snuggs snuggs changed the title <include-html src={uri}> HTML Client Side Include ⚠️ 📖 [DRAFT] <include-html src={uri}> Client Side Include Jul 16, 2017
@snuggs snuggs changed the title ⚠️ 📖 [DRAFT] <include-html src={uri}> Client Side Include ⚠️ 📖 DRAFT: <include-html src={uri}> Client Side Include Jul 16, 2017
@snuggs snuggs changed the title ⚠️ 📖 DRAFT: <include-html src={uri}> Client Side Include ⚠️ 📖 DRAFT:<include-html src={uri}> Client Side Include Jul 16, 2017
@snuggs
Copy link
Member

snuggs commented Jul 16, 2017

@brandondees this could be valuable. Will find the canonical spec reference but will provide value for CSS (and other import resolution strategies). Has done the hard (early) work for us. We just need to prune the bonsai bush. Adding to PR definition as this thread may get long. 💍 💎

https://jakearchibald.com/2016/link-in-body/

@snuggs
Copy link
Member

snuggs commented Jul 16, 2017

I'd like to do some homework to round up other folks' existing examples of how to approach this functionality @brandondees

Homework complete! (See updated description)

@snuggs
Copy link
Member

snuggs commented Jul 16, 2017

@brandondees What do we think about

<include- src=/foo/bar.html>

@brandondees
Copy link
Collaborator Author

I'm still firmly straddling the fence on the use of - as a prefix or suffix in one-word custom tag names... I think it slightly undermines the intention of the - rule and may be error prone.

I went with <include-html> as a starting point because I imagine it's likely for there to be other formats that can be included using a similar mechanism, such as xhtml, xml, csv (include spreadsheet file, get data table embedded), svg, pdf (PDF.JS), with each providing sensible default patterns for how to inline such content into a parent document. Hypothetically I would expect to grow a collection of these components that can then be alphabetically sorted into the family grouping, e.g.

  • <include-html>
  • <include-svg>
  • <include-xhtml>
  • <include-csv>
  • etc.

@grepsedawk
Copy link
Collaborator

grepsedawk commented Jul 17, 2017 via email

@snuggs
Copy link
Member

snuggs commented Jul 17, 2017

I'm still firmly straddling the fence on the use of - as a prefix or suffix

@pachonk @brandondees lemme help you out. MUST start with alphanumeric. Please see #86 for a full synopsis. Description is current.

@brandondees
Copy link
Collaborator Author

brandondees commented Jul 17, 2017 via email

@grepsedawk
Copy link
Collaborator

grepsedawk commented Jul 17, 2017 via email

@snuggs
Copy link
Member

snuggs commented Jul 21, 2017

And it's a shitty lean at that @brandondees @kurtcagle. We are def gonna want to not use webcomponentsjs polyfill (was great while it lasted) but possibly this polyfill site. The polyfill is making errors we didn't create #78

P.S. @brandondees rebased as we are dependent on a test script right now for WHATWG HTML.

@snuggs snuggs changed the title ⚠️ 📖 DRAFT:<include-html src={uri}> Client Side Include ⚠️ 📖 DRAFT: <include-html src={uri}> Client Side Include Jul 22, 2017
@snuggs snuggs changed the title ⚠️ 📖 DRAFT: <include-html src={uri}> Client Side Include ⚠️ 📖 DRAFT: <include- src={uri}> Client Side Include Jul 22, 2017
@snuggs
Copy link
Member

snuggs commented Jul 24, 2017

@brandondees @kurtcagle found a pretty good proposal layout format for future reference. github.com/whatwg/dom/issues/477

@tomalec
Copy link

tomalec commented Aug 24, 2017

Sorry for interrupting. But looking at the implementation in this PR, the behavior is closer to juicy-html.
imported-template uses HTML Imports instead of XHR and the behavior regarding <style>s and <script>s is also applied according to HTML Imports spec.

Personally, I suggest the latter approach. It gives clear, standardized way to handle scripts and styles, de-duping, dependency chains, etc.. But what is even more important, allow to keep dependencies in the partial, then execute/bootstrap them once, even though partial itself is stamped multiple times.

@snuggs
Copy link
Member

snuggs commented Aug 24, 2017

@tomalec no need to apologize! We've been waiting for your input 😄 interesting approach! Care to elaborate? We can get this one merged in ASAP as this sounds pretty kick ass. If you could just provide some guidance i'll take care of the hard stuff😎. The day we can stop thinking about this can't come soon enough. And the webcomponentsjs polyfill is JANKY AF to say the least which is a whole 'nother headache. /cc @brandondees @pachonk

@tomalec
Copy link

tomalec commented Aug 24, 2017

@snuggs do you need something more elaborate than https://starcounter.io/html-partialsincludes-webcomponents-way/ ?

If so please shoot with questions/issues here or at https://github.com/Juicy/imported-template/issues :)

@snuggs
Copy link
Member

snuggs commented Aug 25, 2017

@brandondees DEFINITELY an interesting project. Will definitely have to 🎩👌 tip the cap to @tomalec in "Getting Started" section for includes! Can keep <include- src=...> for tracking progress with HTML Module imports as we are using element- (element name (-) hyphen) format for experimental elements.

Quick question. Why go through all the trouble of using the janky Range instead of creating a bonafied DocumentFragment @tomalec ? At least two better options than that IMHO. Was there specific reasoning? Just curious as I know the pains of dealing with Ranges from contenteditable on a project with @robcole and clearly you are experiencing with Safari. I wonder why there is that inconsistency. 🤔 will need to check with whatwg/dom and webkit teams to see why that is. There should be consistency within that API. Have any reference links where you uncovered this 🐛 ? Seems like it was discovered in Juicy/juicy-html#12, Juicy/imported-template#13, & Juicy/juicy-html#14 and patched in Juicy/juicy-html@2b799a7.

I'd probably remove the safari check and always select this as the spec documentation seems to head (always) nod in this direction irrelevant of vendor implementation.

Going off the Range.contextualFragment Specification the net net outcome is a DocumentFragment. Which can then be inserted using the ParentNode.insertBefore (fragment, parent.firstChild) API.

capture d ecran 2017-08-24 a 22 32 57

@tomalec
Copy link

tomalec commented Aug 26, 2017

Thanks! :)

The only reason we get into all that trouble was to make it work in Safari, I'm not sure if it relevant any longer. Unfortunately, I don't have any reference for webkit bug. This was one of "We need it solve now!" issues ;) If (document.createDocumentFragment()).innerHTML works in Safari, I would really love it instead.

@snuggs
Copy link
Member

snuggs commented Aug 27, 2017

@tomalec not only works with safari. But also has worked with Safari since forever ago ;-). Pretty ancient API. Introduced in DOM in 2005 (DOM 2 I believe)

Shall we champion a PR for you?

@snuggs snuggs closed this Oct 16, 2017
@snuggs snuggs deleted the import-html branch October 16, 2017 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants