Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function C($el) {
console.log($el[0])
}
console.log($el)
})
t.todo('subselect nodes', t => {
let $foo = $``
console.log('bar')
let $bar = $foo.$(`bar`)
t.is($bar[0], $foo[0].firstChild)
})
t.skip('live nodes list as reference under the hood', t => {
// FIXME: that's insustainable for now: we have to extend Spect class from Proxy-ed prototype,
// providing numeric access to underneath store, like NodeList etc.
// The proxy prototype looks
let el = document.createElement('div')
el.appendChild(document.createElement`div`)
let $children = $(el.childNodes)
t.is($children.length, 1)
el.appendChild(document.createElement`div`)
t.is($children.length, 2)
})
t.todo('rebinding to other document', async t => {
let { document } = await import('dom-lite')
t.skip('is: simple element with no content should (?) be upgraded', t => {
let $el = $`<div is=""> {
console.log($el)
}}/>`
})
t.skip('is: existing elements with `is` attr should be hydrated', t => {
let $el = $`<div is=""></div>`
$el.is(FooBar)
// TODO: and simple tags
// `<div is=""></div>`
})
t.skip('is: existing element with `is` attr not matching the fn name should throw error', t => {
$`<div is="">`.is(FooBar)
})
</div></div>
let log = []
let $a = spect({})
await $a.use(fn)
t.is(log, ['x'])
await $a.use(fn)
t.is(log, ['x'])
await $a.use([fn, fn])
t.is(log, ['x'])
await $a.update()
t.is(log, ['x', 'x'])
function fn(el) { log.push('x') }
})
t.skip('use: same aspect different targets', t => {
let log = []
function fx([el]) {
log.push(el.tagName)
// return () => log.push('destroy ' + el.tagName)
}
let $el = spect({ tagName: 'A' }).use(fx)
t.is($el.target.tagName, log[0])
t.is(log, ['A'])
$el.target.innerHTML = '<span></span>'
$($el.target.firstChild).use(fx)
t.deepEqual(log, ['A', 'SPAN'])
})
// this
// args
$('', () => {
})
})
t.skip('core: props', t => {
$('', {})
})
t.skip('core: children', t => {
$('', a, b, c)
})
t.skip('core: props + children', t => {
$('', { a, b, c }, a, fn, c)
})
// component tree https://github.com/scrapjs/permanent/issues/2)
t.skip('core: text', t => {
$(target, 'abc')
})
t.skip('core: Element', t => {
$(target, Element)
})
t.skip('core: vdom', t => {
// DO via plugins
$(target, react | vdom)
})
t.skip('core: class', t => {
class Component {
})
t.skip('core: props', t => {
$('', {})
})
t.skip('core: children', t => {
$('', a, b, c)
})
t.skip('core: props + children', t => {
$('', { a, b, c }, a, fn, c)
})
// component tree https://github.com/scrapjs/permanent/issues/2)
t.skip('core: text', t => {
$(target, 'abc')
})
t.skip('core: Element', t => {
$(target, Element)
})
t.skip('core: vdom', t => {
// DO via plugins
$(target, react | vdom)
})
t.skip('core: class', t => {
class Component {
constructor() { }
mount() { }
update() { }
unmount() { }
render() { } // optional
})
t.skip('core: array of elements', t => {
$([a, b, c], () => {
})
})
t.skip('core: mixed array', t => {
$(['.a', b, '.c'], () => {
})
})
// edge cases
t.skip('core: null target')
t.skip('core: fake target')
t('core: generators aspects')
t('core: async aspects')
// handlers
t.skip('core: function', t => {
// this
// args
$('', () => {
})
})
t.skip('core: props', t => {
$('', {})
})
t.skip('core: children', t => {
$('', a, b, c)
})
t.skip('core: props + children', t => {
$('', { a, b, c }, a, fn, c)
})
// component tree https://github.com/scrapjs/permanent/issues/2)
t.skip('core: text', t => {
$(target, 'abc')
})
t.skip('core: Element', t => {
import t from 'tst'
import enhook from './enhook.js'
import { useChannel, useEffect } from '..'
import { time } from 'wait-please'
t.skip('useChannel: initialize', async t => {
let log = []
let a = enhook(() => {
let [ value, { loading }] = useChannel('charlie')
log.push('a', value, loading)
})
let b = enhook(() => {
let [ value, { loading }] = useChannel('charlie', 1)
log.push('b', value, loading)
})
let c = enhook(() => {
let [ value, setValue, { loading }] = useChannel('charlie')
log.push('c', value, loading)
useEffect(() => {
let $f = $`<form><input name="a"><input name="b"></form>`
let $form = $($f)
t.is($f, $form)
t.is($form[0].childNodes.length, 2)
t.is($form[0], $f[0])
})
t.skip('array map should work fine', t => {
let $a = $`<a>`
let $b = $a.map(x => x.html`<span>`)
t.is($a, $b)
})
t.skip('negative, positive indices')
t.skip('Set methods')
t.skip('call subfilters elements')
t.todo('promise postpones properly / effects are bound', async t => {
let $a = $`</span></a><a> html``}/>`
await $a
t.is($a[0].innerHTML, '<span class="x"></span>')
})
t.todo('create document fragment is ok', t => {
let $d = $(document.createDocumentFragment())
t.is($d.length, 0)
})</a>
let child1 = el.firstChild
t.equal(child1, child)
function fn(el) { }
})
t('html: functional components create element', t => {
let log = []
let el = html`<${el => {
let e = document.createElement('a')
log.push(e)
return e
}}/>`
t.is(log, [el])
})
t.skip('html: use assigned via prop', t => {
let log = []
let el = html`<a> {
log.push(el.tagName.toLowerCase())
let e = document.createElement('b')
return e
}}/>`
t.is(log, ['a'])
t.is(el.tagName.toLowerCase(), 'b')
})
t.todo('html: is=string works fine', t => {
let a = html`</a><a is="">`
})
t('html: props passed to use are actual object', t => {
let a = html``</a>