-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Defining a Non-Script Native HTML Component Model #9815
Comments
For the sake of this PR brief, I sought to follow the WHATWG guidelines laid out here and intentionally did not go deep on syntax in the brief. Regarding syntax specifics, I have conducted some research and gathered some thoughts here for further discussion, but I'm fully open to tossing these in favor of something better. Hopefully, this can help to stir some fruitful discussion.
|
The problem
Modern web development heavily relies on component-based architectures, allowing for modular and reusable code. However, currently, this necessitates the use of JavaScript libraries or frameworks, which can result in performance overhead, complex build setups, and a steeper learning curve for newcomers to web development. There exists a gap in native HTML/CSS for defining, importing, and using reusable components in a modular fashion.
** This does not solve the same problem that web components solve. They are both useful, but needfully separate.
Existing solutions
JavaScript Frameworks and Libraries
CSS Preprocessors
Server-Side Includes (SSI)
HTML Templates
<template>
tag in HTML allows for the definition of inert HTML templates that can be activated via JavaScript, yet they require JavaScript for manipulation and rendering.Proposed solution
I would propose a solution that expands upon the existing HTML/CSS syntax to introduce native HTML components with the following characteristics:
Declarative Syntax
<component>
could be introduced, which allows for the definition, import, and use of reusable components directly within HTML files.CSS Custom Properties
Attribute Binding
<slot>
comoponent to support binding content to an attribute on the slotted element instead using a named slot. Alternatively, a new element like<attr>
could be introduced which would operate as an element solely bound to the named attribute on the component usage's root and would share the same general syntax as the<slot>
element.Content Slotting
<slot>
element to enable content slotting within components using named and default slot(s).Component Nesting
Native Import/Export
Additional considerations
Direct DOM Injection Over Shadow DOM
Backward Compatibility
Performance
The text was updated successfully, but these errors were encountered: