
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
data-components
Advanced tools
Tiny component structure for web applications
$ npm install data-components --save
Or you can simply copy and paste the minified standalone version that lives under dist/
There are plenty of options to architect a web application out there but most of them often assume that you're working on a SPA. That alone will add a lot of stuff that you might not want at all. Data binding, custom messaging system and virtual DOM to name a few.
Sometimes you just need something simple to kick things off without having to worry about naming conventions and programming paradigms. That's how this library was born.
Let's implement the simplest todo list app.
<!-- Create our todo list element passing some initial values -->
<ul data-component="todo" data-values="foo,bar"></ul>
<!-- Let's use a input field to read the user input -->
<input data-component="input" placeholder="What to do?">
Ok, now that we have our markup in place, let's implement the application.
// Todo component
class Todo {
constructor(el, options) {
this.el = el;
// Read from initial values
this.todos = options.values.split(',');
this.render();
}
// Add items to the list
add(todo) {
this.todos.push(todo);
this.render();
}
// Render the list to the DOM
render() {
this.el.innerHTML = this.todos.map(todo => `<li>${todo}</li>`).join('');
}
}
// User input component
class Input {
constructor(el, options, sandbox) {
const todo = sandbox.get('todo');
// Submit value to "todo" component when hitting the enter key
el.addEventListener('keydown', e => {
if (e.keyCode === 13) {
todo.add(el.value);
el.value = '';
el.focus();
}
});
}
}
// Bootstrap components (UMD build exposes `components()`)
components({
todo: Todo,
input: Input
});

It works with just a few lines of code :tada:
Check out the demo page for a slightly more complex example.
For more detailed instructions on how the project works and how to use it, please check the user guide.
MIT © Rafael Rinaldi
FAQs
Tiny component structure for web applications
We found that data-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.