Reference › Project
clarusjs 0.16.0
All releases · [email protected] on npm
Minor Changes
(name)on a component that doesn't declare@event nameis the DOM event on what it renders, as in Vue:<likeButton (click)="likes++">hears the click on its<button>, with the DOM event as$event. A declared@eventstill wins (the DOM event of the same name doesn't also fire).clarusjs checktypes$eventas the DOM event and still reports a name that is neither an@eventnor a DOM event. #508- Components from libraries. List installed component libraries,
clarusjs({ components: { libraries: ['@clarusjs/ui-primitives'] } })(or{ from, prefix }for your own prefix), and their components work by name without@import:<ui-tabs>,<ui-tab-list>. A library describes itself in its package.json,"clarusjs": { "components": "./src", "prefix": "ui" }, and each component is imported as<package>/<file>. An@importwins, then your own components, then libraries; a name two libraries share is an error naming both. The dev server, builds andclarusjs checkwrite the names and the configuredcomponents.dirsto.clarusjs/components.json, which the language server and the TypeScript content mapper read.@clarusjs/ui-primitivesdescribes itself with theuiprefix. #513 - Lint fixes. A finding may carry a
fix({ start, end, text });one-root's wraps the component's top level in<fragment>, which renders the same HTML (a root<fragment>now renders like its children written at the top level: whitespace-only text between them is dropped, and so is the line break right after<fragment>). A<script>,<style>or declaration (@input, any@import,@event…) between the roots moves above them first, in order: wrapped, it would no longer be the component's, and at the top level its place doesn't matter.clarusjs check --fixwrites fixes to the.tsclfiles before checking (with--json, the files it rewrote are listed on stderr),applyFixes(source, messages)fromclarusjs/compilerapplies them in code, ESLint's--fixapplies them throughclarusjs/template, and the language server offers each as a quick fix. A project's own rules can pass a fix asreport(start, message, fix). #512 - One root per component,
<fragment>, and@extends. -<fragment>groups elements without rendering one, anywhere in a template (a component's root, an@ifbranch, a@forrow, slot content). It takes no attributes, and a component whose root is one takes none from its parent:clarusjs checkreports anyclass, attribute or(event)written on its tag. - Theone-rootlint rule warns about a component without one root element (files under apagesorlayoutsfolder, and whole documents, are exempt; a layout kept elsewhere is warned about), so what a parent passes always has one place to land. It becomes an error in a later minor. -@extends button(orinput,textarea,select,option,a,img,form,label,details,dialog): the component takes every attribute of that element, typed byclarusjs check, onto its root, which must be that element. - A stateful@extendsisland kept in place when its parent re-renders takes the new passed attributes (a parent's[disabled]changing reaches its root). - theme-docs: the page head and the contents part render a<fragment>(same HTML). The agent guidance teaches one root. #510
Patch Changes
- Image attributes (
src,srcset,poster) accept object URLs (blob:), so a bound<img [src]>can preview a picked file.hrefstill refuses them, and attributes that load a page or a script stay static only. #537 - Attributes passed to a component also land on its root when the top level is one
@if…@elsewith a single element in each branch (outside islands): the branch that renders gets them. A button that renders an<a>when givenhrefkeepsaria-*,data-*,idandstyleeither way. #493 attach="visible"attaches in real browsers: it watched<cl-island>itself, which isdisplay: contentsand so never intersects; it now watches what the island holds. #521