typed-dom
Advanced tools
Comparing version 0.0.264 to 0.0.265
@@ -67,2 +67,3 @@ import { shadow, frag, html, svg, text, define, defrag } from './dom'; | ||
assert(define(define(html('a', { href: '' })), { href: null }).matches(':not([href])')); | ||
assert(define(html('html'), frag(['a', 'b']).childNodes).innerHTML === 'ab'); | ||
assert(define(html('html', [frag(['a', text('b')])]), 'c').innerHTML === 'c'); | ||
@@ -69,0 +70,0 @@ assert(define(html('html', 'a'), [frag(['b', text('c')])]).innerHTML === 'bc'); |
import { Symbol, document } from 'spica/global'; | ||
import { hasOwnProperty } from 'spica/alias'; | ||
import { isArray, hasOwnProperty } from 'spica/alias'; | ||
import { memoize } from 'spica/memoize'; | ||
@@ -153,3 +153,3 @@ | ||
} | ||
function defineChildren<T extends ParentNode & Node>(node: T, children: Children): T { | ||
function defineChildren<T extends ParentNode & Node>(node: T, children: Children | readonly (string | Node)[]): T { | ||
if (children === void 0) return node; | ||
@@ -159,7 +159,8 @@ if (typeof children === 'string') { | ||
} | ||
else if (node.firstChild) { | ||
else if (!isArray(children) || node.firstChild) { | ||
node.replaceChildren(...children); | ||
} | ||
else { | ||
for (const child of children) { | ||
for (let i = 0; i < children.length; ++i) { | ||
const child = children[i]; | ||
typeof child === 'object' | ||
@@ -166,0 +167,0 @@ ? node.appendChild(child) |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.264", | ||
"version": "0.0.265", | ||
"description": "A value-level and type-level DOM builder.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -67,2 +67,3 @@ import { shadow, frag, html, svg, text, define, defrag } from './dom'; | ||
assert(define(define(html('a', { href: '' })), { href: null }).matches(':not([href])')); | ||
assert(define(html('html'), frag(['a', 'b']).childNodes).innerHTML === 'ab'); | ||
assert(define(html('html', [frag(['a', text('b')])]), 'c').innerHTML === 'c'); | ||
@@ -69,0 +70,0 @@ assert(define(html('html', 'a'), [frag(['b', text('c')])]).innerHTML === 'bc'); |
import { Symbol, document } from 'spica/global'; | ||
import { hasOwnProperty } from 'spica/alias'; | ||
import { isArray, hasOwnProperty } from 'spica/alias'; | ||
import { memoize } from 'spica/memoize'; | ||
@@ -153,3 +153,3 @@ | ||
} | ||
function defineChildren<T extends ParentNode & Node>(node: T, children: Children): T { | ||
function defineChildren<T extends ParentNode & Node>(node: T, children: Children | readonly (string | Node)[]): T { | ||
if (children === void 0) return node; | ||
@@ -159,7 +159,8 @@ if (typeof children === 'string') { | ||
} | ||
else if (node.firstChild) { | ||
else if (!isArray(children) || node.firstChild) { | ||
node.replaceChildren(...children); | ||
} | ||
else { | ||
for (const child of children) { | ||
for (let i = 0; i < children.length; ++i) { | ||
const child = children[i]; | ||
typeof child === 'object' | ||
@@ -166,0 +167,0 @@ ? node.appendChild(child) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
673068
15832