-
Notifications
You must be signed in to change notification settings - Fork 376
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
Declarative syntax for custom elements #136
Comments
I think a neat way of doing this is allowing people to send a <!doctype html>
<html>
<head>
<template id="foo" data-custom>foo</template>
<template id="bar" data-custom>bar</template>
<template id="baz" data-custom>baz</template>
<script>
for(let template of Array.from(document.head.querySelectorAll("template[data-custom]")))
{
customElements.define("x-" + template.id, class extends HTMLElement {}, {template: template.content});
}
</script>
</head>
<body>
<x-foo></x-foo>
<x-bar></x-bar>
<x-baz></x-baz>
</body>
</html> Then, when created, |
And by “immutable” I mean “unremovable and invisible to the outside world”. |
Apple proposed something similar in 2003: https://lists.w3.org/Archives/Public/public-webapps/2013OctDec/0794.html and got veto'ed by Google. I agree that having a mechanism to automatically instantiate a shadow root with a template content would be useful. |
That is #135 though. I suggest we close this issue since there's no concrete proposal and we probably want to wait a while to see what libraries come up with. |
Okay. Let's close this. |
Title: Declarative syntax for custom elements (bugzilla: 28545)
Migrated from: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28545
comment: 0
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28545#c0
Ryosuke Niwa wrote on 2015-04-22 23:49:56 +0000.
See https://lists.w3.org/Archives/Public/public-webapps/2013OctDec/0418.html
At some point (perhaps post-V1), there should be a convenient declarative syntax that combines script and a template to define a custom element. JavaScript frameworks on top of web components provide something like this. Perhaps with field experience we can make a standardized common syntax.
Specifically, such a syntax needs to be compatible with an isolated cross-origin component.
The text was updated successfully, but these errors were encountered: