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

What does return content attribute of template element? #10322

Closed
dSalieri opened this issue May 7, 2024 · 2 comments
Closed

What does return content attribute of template element? #10322

dSalieri opened this issue May 7, 2024 · 2 comments

Comments

@dSalieri
Copy link

dSalieri commented May 7, 2024

You can find in spec the next:

The content getter steps are to return template's template contents, if the template contents is not a ShadowRoot node; otherwise null.

We see that the content attribute may return the null value, interesting...

Maybe template contents algorithm may say more?

  1. Let doc be the template element's node document's appropriate template contents owner document.

  2. Create a DocumentFragment object whose node document is doc and host is the template element.

  3. Set the template element's template contents to the newly created DocumentFragment object.

Well, the template contents return the DocumentFragment constantly.

So where is the case when template.content return the null value?


I found the case when template contents of template has a shadow root.

  1. Attach a shadow root with declarative shadow host element, mode, clonable, serializable, delegatesFocus, and "named". If an exception is thrown, then catch it, report the exception, insert an element at the adjusted insertion location with template, and return.

  2. Let shadow be declarative shadow host element's shadow root.

  3. Set shadow's declarative to true.

  4. Set template's template contents property to shadow.

  5. Set shadow's available to element internals to true.

But how can I see reflection of 4 step? When and where can I write template.content and get the null value? Thanks.

@domenic
Copy link
Member

domenic commented May 7, 2024

These sorts of "help" questions are best for StackOverflow.

@domenic domenic closed this as completed May 7, 2024
@dSalieri
Copy link
Author

dSalieri commented May 7, 2024

@domenic do you think guys on SO knows answer when this thing appeared in 2023?

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

No branches or pull requests

2 participants