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

Implement slot-like replacement for <content select> #2278

Closed
justinbmeyer opened this issue Feb 18, 2016 · 4 comments
Closed

Implement slot-like replacement for <content select> #2278

justinbmeyer opened this issue Feb 18, 2016 · 4 comments
Assignees
Milestone

Comments

@justinbmeyer
Copy link
Contributor

Background on slots:

https://webkit.org/blog/4096/introducing-shadow-dom-api/
https://www.w3.org/TR/shadow-dom/#distributions
https://www.w3.org/TR/shadow-dom/#dfn-slot-element

content && template-NAME

Example 1

Shadow DOM:

  <b>Name</b>:
  <content name="fullName">
      <content name="firstName"></content>
      <content name="lastName"></content>
  </content><br>
  <b>Email</b>: <content name="email">Unknown</content><br>
  <b>Address</b>: <content name="address">Unknown</content>

User DOM:

<my-contact>
  <title-template><span>Commit Queue</span></title-template>
  <email-template><a href="mailto:commit-queue@webkit.org">commit-queue@webkit.org</a></email-template>
  <address-template><span>One Infinite Loop, Cupertino, CA 95014</span></address-template>
</my-contact>
@justinbmeyer justinbmeyer added this to the 2.4.0 milestone Feb 18, 2016
@justinbmeyer justinbmeyer self-assigned this Feb 18, 2016
@justinbmeyer justinbmeyer changed the title Implement <slot> as a replacement for <content select> Implement <can-slot> as a replacement for <content select> Feb 18, 2016
@justinbmeyer justinbmeyer changed the title Implement <can-slot> as a replacement for <content select> Implement slot-like replacement for <content select> Feb 18, 2016
@BigAB
Copy link
Contributor

BigAB commented Feb 19, 2016

Why <content name=""></content> and <*-template></*-template>?

Why not just use slot="" and <slot name=""></slot>?

@justinbmeyer
Copy link
Contributor Author

@BigAB I mentioned a few reasons in the bitovi chat a while ago. Three major reasons:

  1. We probably don't want to overwrite a behavior the browser might provide. <content> was probably a mistake if <content> was actually ever supported.
  2. It's easier, and CanJS is already setup to identify sub-templates that are <tag> based and not attribute based.
  3. Attribute-based tags need to have an element associated with them. Say I wanted to position pure text content like: {{first}} {{last}}. You couldn't do that, you'd have to add a <span> or some other element. Also, it seems that the spec leaves in <slot> elements. Not sure I like that.

@justinbmeyer
Copy link
Contributor Author

To be clear, I'm not sold on <template> and <content> and while <tags> are easier than attri=butes, the burden of making that work shouldn't keep us from using them. However, I'm wary of always having to have that <span>.

One other point, all the <x-template> renders will be put on the viewModel as templates. This would allow the shadow DOM to also be written like:

<b>Name</b>:
  {{#if templates@fullName}}
    {{{ templates.fullName }}}
  {{else}}
     {{{ templates.firstName }}} {{{templates.lastName}}}
  {{/if}}<br>
  <b>Email</b>: {{{templlates.email}}<br>
  <b>Address</b>: {{{templates.address}}}

However, I like using elements for simplifying setting up default content.

@justinbmeyer
Copy link
Contributor Author

Moving to can-component

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

No branches or pull requests

2 participants