pax_global_header00006660000000000000000000000064144311443710014514gustar00rootroot0000000000000052 comment=25eabb104d50e160cd4e4acd9eed2eacb32b332b crelt-1.0.6/000077500000000000000000000000001443114437100126315ustar00rootroot00000000000000crelt-1.0.6/.gitignore000066400000000000000000000000341443114437100146160ustar00rootroot00000000000000/node_modules .tern-* /dist crelt-1.0.6/LICENSE000066400000000000000000000021011443114437100136300ustar00rootroot00000000000000Copyright (C) 2020 by Marijn Haverbeke Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. crelt-1.0.6/README.md000066400000000000000000000013741443114437100141150ustar00rootroot00000000000000# CRELT Tiny DOM-element creation utility. Exports a single (default) value, which is a function that you call with: - A tag name string or DOM element. - Optionally an attribute object mapping names to values. When the values are strings, they are added to the element with `setAttribute`. When they have another type, they are assigned as regular properties (mostly useful for event handlers via `onclick` and such). When an attribute's value is null or undefined, it is not assigned. - Any number of children, which may be null (ignored), strings (added as text nodes), DOM nodes (added), or arrays (each element is added separately). The function returns a DOM element. ## License This software is licensed under an MIT license. crelt-1.0.6/index.d.ts000066400000000000000000000004301443114437100145270ustar00rootroot00000000000000type Child = string | Node | null | undefined | readonly Child[] export default function crelt(elt: string | HTMLElement, attrs: {[attr: string]: any}, ...children: Child[]): HTMLElement export default function crelt(elt: string | HTMLElement, ...children: Child[]): HTMLElement crelt-1.0.6/index.js000066400000000000000000000016671443114437100143100ustar00rootroot00000000000000export default function crelt() { var elt = arguments[0] if (typeof elt == "string") elt = document.createElement(elt) var i = 1, next = arguments[1] if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) { for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) { var value = next[name] if (typeof value == "string") elt.setAttribute(name, value) else if (value != null) elt[name] = value } i++ } for (; i < arguments.length; i++) add(elt, arguments[i]) return elt } function add(elt, child) { if (typeof child == "string") { elt.appendChild(document.createTextNode(child)) } else if (child == null) { } else if (child.nodeType != null) { elt.appendChild(child) } else if (Array.isArray(child)) { for (var i = 0; i < child.length; i++) add(elt, child[i]) } else { throw new RangeError("Unsupported child node: " + child) } } crelt-1.0.6/package.json000066400000000000000000000014031443114437100151150ustar00rootroot00000000000000{ "name": "crelt", "version": "1.0.6", "description": "Tiny DOM-element-creation utility", "main": "dist/index.cjs", "type": "module", "exports": { "import": "./index.js", "require": "./dist/index.cjs" }, "module": "index.js", "types": "index.d.ts", "scripts": { "prepare": "rollup -c" }, "repository": { "type": "git", "url": "git+https://github.com/marijnh/crelt.git" }, "keywords": [ "dom", "creation", "crel" ], "author": "Marijn Haverbeke ", "license": "MIT", "bugs": { "url": "https://github.com/marijnh/crelt/issues" }, "homepage": "https://github.com/marijnh/crelt#readme", "devDependencies": { "rollup": "^2.0.5", "rollup-plugin-copy": "^3.4.0" } } crelt-1.0.6/rollup.config.js000066400000000000000000000004151443114437100157500ustar00rootroot00000000000000import copy from "rollup-plugin-copy" export default { input: "index.js", output: { file: "dist/index.cjs", format: "cjs", exports: "default" }, plugins: [ copy({targets: [{src: "index.d.ts", dest: "dist", rename: () => "index.d.cts"}]}) ] }