x-element
_________
/ /__ __\ \
/ / \ \ / \ \
\ \ /_\_\ / /
\_\_____/_/
A dead simple basis for custom elements. It provides the following functionality:
- Efficient DOM generation and data binding using your preferred templating engine
- Automatic
.propertyto[attribute]reflection (opt-in) - Automatic
[attribute]to.propertysynchronization (one-directional, on connected) - Simple and efficient property observation and computation
- Simple delegated event handling
- Useful error messages
See SPEC.md for all the deets.
Save a local copy to your project:
curl -O https://raw.githubusercontent.com/Netflix/x-element/main/x-element.js \
-O https://raw.githubusercontent.com/Netflix/x-element/main/x-parser.js \
-O https://raw.githubusercontent.com/Netflix/x-element/main/x-template.jsThen import it:
import XElement from '/path/to/x-element.js';...or load it directly from the web:
import XElement from 'https://deno.land/x/element/x-element.js';...or use an importmap:
<script type="importmap">
{
"imports": {
"@netflix/x-element": "https://deno.land/x/element/x-element.js"
}
}
</script>Then import it using a bare module specifier...
import XElement from '@netflix/x-element';...or use a package manager:
npm install @netflix/x-elementThen import it using a bare module specifier...
import XElement from '@netflix/x-element';- No compilation step is necessary for adoption, just import
x-element.js - Implement a minimal set of generalized functionality
- Make as few design decisions as possible
- Presume adopters are browser experts already (stay out of their way)
- Follow web platform precedents whenever possible
- Remain compatible with any browser which fully supports custom elements
- Prioritize simple syntax and useful comments in the code itself
- Avoid making developers learn new proprietary stuff
- Zero dependencies
npm install && npm start
Then...