@wrnrlr/prelude 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrnrlr/prelude",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "exports": "./src/mod.ts",
5
5
  "compilerOptions": {
6
6
  "strict": false,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wrnrlr/prelude",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "author": "Werner Laurensse",
6
6
  "description": "A signal based frontend library with fine-grained reactivity",
7
7
  "main": "./src/mod.ts",
package/src/runtime.ts CHANGED
@@ -283,7 +283,7 @@ function eventHandler(e:any) {
283
283
  }
284
284
 
285
285
  function setAttribute(node:Node, name:string, value?:string):any {
286
- value ? node.setAttribute(name, value) : node.removeAttribute(name)
286
+ value===undefined || value===null ? node.removeAttribute(name) : node.setAttribute(name, value)
287
287
  }
288
288
 
289
289
  function setAttributeNS(node:Node, ns:string, name:string, value?:string):any {
@@ -30,6 +30,10 @@ testing('h with basic element', {skip:true}, async test => {
30
30
  await test('tag with id', () => assertHTML(h('#a'), '<div id="a"></div>'))
31
31
  await test('tag with class', () => assertHTML(h('.a'), '<div class="a"></div>'))
32
32
  await test('tag with id & classes', () => assertHTML(h('i#a.b.c'), '<i id="a" class="b c"></i>'))
33
+ await test('tag with tag class and prop class', () => assertHTML(h('hr.a', {class:'b'}), '<hr class="a b">'))
34
+ await test('tag with tag class and dynamic prop class', () => assertHTML(h('hr.a', {class:()=>'b'}), '<hr class="a b">'))
35
+ await test('tag with tag class and undeefined prop class', () => assertHTML(h('hr.a', {class:undefined}), '<hr class="a">'))
36
+ await test('tag with tag class and dynamic undeefined prop class', () => assertHTML(h('hr.a', {class:()=>undefined}), '<hr class="a">'))
33
37
  await test('no props or children', () => assertHTML(h('hr'), '<hr>'))
34
38
  await test('boolean content', () => assertHTML(h('b',true), '<b>true</b>'))
35
39
  await test('string content', () => assertHTML(h('b','A'), '<b>A</b>'))
@@ -39,11 +43,12 @@ testing('h with basic element', {skip:true}, async test => {
39
43
  // await test('regex content', () => assertHTML(h('b',/\w/), '<b>/\\w/</b>'))
40
44
  await test("signal content", () => assertHTML(h('i',()=>1), '<i>1</i>'))
41
45
  await test('array content', () => assertHTML(h('i',['A',1,2n]), '<i>A12</i>'))
42
- await test('style attribute', () => assertHTML(h('hr',{style:'color:red'}), '<hr style="color: red;">'))
43
- await test('htmlFor attribute', () => assertHTML(h('label',{htmlFor:'a'}), '<label for="a"></label>'))
44
- await test('ref attribute', () => assertHTML(h('hr',{ref:el=>el.setAttribute('a','1')}), '<hr a="1">'))
45
- await test('classList attribute', () => assertHTML(h('hr', {classList:()=>({a:true})}), '<hr class="a">'))
46
- await test('class from tag & attribute', () => assertHTML(h('hr.a',{class:'b'}), '<hr class="a b">'))
46
+ await test('ref property', () => assertHTML(h('hr',{ref:el=>el.setAttribute('a','1')}), '<hr a="1">'))
47
+ await test('style property sets style attribute', () => assertHTML(h('hr',{style:'color:red'}), '<hr style="color: red;">'))
48
+ await test('htmlFor property sets for attribute', () => assertHTML(h('label',{htmlFor:'a'}), '<label for="a"></label>'))
49
+ await test('classList property sets class attribute', () => assertHTML(h('hr', {classList:()=>({a:true})}), '<hr class="a">'))
50
+ await test('custom attribute', () => assertHTML(h('hr', {'attr:a':'b'}), '<hr a="b">'))
51
+ await test('custom empty attribute', () => assertHTML(h('hr', {'attr:data-a':''}), '<hr data-a="">'))
47
52
  })
48
53
 
49
54
  function assertText(t, e, msg) { assertEquals(t(), e, msg) }