diff --git a/dom.js.md b/dom.js.md index 3e95d60..fff60c4 100644 --- a/dom.js.md +++ b/dom.js.md @@ -2,12 +2,29 @@ import { el, dom } from './dom.js ``` -## el(attr, children) +## el.TAG(attr, children) → Element + +This is a proxy for `DomHelper.create`, saving you a few characters. TAG can be any valid HTML tag, attr is an object of attributes to assign using `apply()`, and children is an array of children to append using `append()`. ## class dom (DomHelper) -### create(element, attr, children) +### create(element, attr, children) → Element ### apply(element, attributes) -### append(element, children) \ No newline at end of file +Apply will apply all values in the **attributes** object as attributes to the element, with a few exceptions: + +- If the value of the attribute is null, the attribute will be removed rather than set. +- If the value of the attribute is true, the attribute value will be the same as the attribute name. +- If the attribute name starts with `on:`, for example `on:click`, the value must be a callable which will be set as a listener for the specified event. No attribute will be added in this case. + +Note: Since this method is called from `el()` and `create()`, the above rules are valid with those methods as well. + +### append(element, children) + +Append will add all values and elements in the **children** array as children to the element, with a few exceptions: + +- If the child is `null`, it will be skipped. This lets you add children conditionally by nulling them if undesired. +- If the child is a string, it will be added as a text node. + +Note: Since this method is called from `el()` and `create()`, the above rules are valid with those methods as well. \ No newline at end of file