boreDOM 另一个无聊的 JS 框架

  • About: On 12-Jan-2025, the author presents "boreDOM", a new JS framework created out of boredom. Its main motivation is to have a simple DOM manipulation framework that can fit the scenario of having HTML in.html files, CSS in.css files, and JS in.js files, reusing existing HTML nodes with a small JS footprint.
  • The idea: Use <template> elements with a data-component attribute to register custom element tags. The framework reads these attributes and stamps the template content as needed.
  • The logic: A matching.js file can be set with a <script> tag. This file is imported dynamically and exports functions for component connection and rendering. It also supports helper attributes like on for handling custom events.
  • A simple counter: Slots are supported through the .slots attribute. A simple counter example shows how to handle events to increase or decrease the counter value and set the slot value.
  • Some particularities: It brings features like references to elements through data-ref attributes, shadow-dom support, passing aria-* and role=* attributes, creating components in JS, batching renders, being typed with JSDoc, and a comprehensive test suit.
  • Conclusion: The author is happy if the framework is useful to others. There is also a ranty webpage for more information. A caveat is that component JS code being imported dynamically makes it hard to use bundlers or non-standard tech before laying out UI components.
阅读 7
0 条评论