mini-van-plate
Advanced tools
Comparing version 0.3.6 to 0.3.7
{ | ||
"name": "mini-van-plate", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "A minimalist template engine for DOM generation and manipulation, working for both client-side and server-side rendering", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -151,3 +151,3 @@ # **Mini-Van**: A Minimalist Template Engine for Client/Server-side Rendering without JSX | ||
import { serve } from "https://deno.land/std@0.184.0/http/server.ts" | ||
import van from "https://deno.land/x/minivan@0.3.6/src/van-plate.js" | ||
import van from "https://deno.land/x/minivan@0.3.7/src/van-plate.js" | ||
@@ -190,3 +190,3 @@ const {a, body, li, p, ul} = van.tags | ||
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.38/deno-dom-wasm.ts" | ||
import van from "https://deno.land/x/minivan@0.3.6/src/mini-van.js" | ||
import van from "https://deno.land/x/minivan@0.3.7/src/mini-van.js" | ||
@@ -238,3 +238,3 @@ const document = new DOMParser().parseFromString("", "text/html")! | ||
You can find all relevant **Mini-Van** files in this [Download Table](https://vanjs.org/minivan#download-table). | ||
You can find all relevant **Mini-Van** files in this [Download Table](https://vanjs.org/minivan#download-table). | ||
@@ -241,0 +241,0 @@ ## API Reference |
@@ -10,3 +10,3 @@ export type Primitive = string | number | boolean | bigint | ||
export type ChildDom<ElementType, TextNodeType> = Primitive | ElementType | TextNodeType | ||
| readonly ChildDom<ElementType, TextNodeType>[] | ||
| readonly ChildDom<ElementType, TextNodeType>[] | null | undefined | ||
@@ -20,3 +20,3 @@ type AddFunc<ElementType, TextNodeType> = | ||
type Tags<ElementType, TextNodeType> = { | ||
interface Tags<ElementType, TextNodeType> { | ||
readonly [key: string]: TagFunc<ElementType, TextNodeType> | ||
@@ -27,3 +27,3 @@ } | ||
// specialized DOM elements. | ||
type BrowserTags = Tags<Element, Text> & { | ||
interface BrowserTags extends Tags<Element, Text> { | ||
// Register known element types | ||
@@ -145,3 +145,3 @@ // Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element | ||
export type Van = { | ||
export interface Van { | ||
readonly vanWithDoc: VanWithDoc | ||
@@ -148,0 +148,0 @@ readonly add: AddFunc<Element, Text> |
@@ -6,3 +6,3 @@ /// <reference types="./mini-van.d.ts" /> | ||
// Aliasing some builtin symbols to reduce the bundle size. | ||
let Obj = Object | ||
let Obj = Object, _undefined | ||
@@ -14,3 +14,4 @@ let vanWithDoc = doc => { | ||
add: (dom, ...children) => { | ||
for (let child of children.flat(Infinity)) dom.appendChild(toDom(child)) | ||
for (let child of children.flat(Infinity)) | ||
if (child != _undefined) dom.appendChild(toDom(child)) | ||
return dom | ||
@@ -17,0 +18,0 @@ }, |
@@ -9,3 +9,3 @@ type Primitive = string | number | boolean | bigint | ||
export type ChildDom = Primitive | Element | readonly ChildDom[] | ||
export type ChildDom = Primitive | Element | readonly ChildDom[] | null | undefined | ||
@@ -12,0 +12,0 @@ export type TagFunc = (first?: Props | ChildDom, ...rest: readonly ChildDom[]) => Element |
@@ -39,3 +39,3 @@ /// <reference types="./van-plate.d.ts" /> | ||
const toStr = children => children.flat(Infinity).map( | ||
const toStr = children => children.map( | ||
c => Object.getPrototypeOf(c) === elementProto ? c.render() : escape(c.toString())).join("") | ||
@@ -49,7 +49,9 @@ | ||
(v ? " " + k : "") : ` ${k}=${JSON.stringify(v)}`).join("") | ||
const flattenedChildren = children.flat(Infinity).filter(c => c != null) | ||
return {__proto__: elementProto, name, propsStr, | ||
childrenStrs: children.length > 0 ? [toStr(children)] : []} | ||
childrenStrs: flattenedChildren.length > 0 ? [toStr(flattenedChildren)] : []} | ||
}, { get: (tag, name) => tag.bind(null, name) }) | ||
const add = (dom, ...children) => { | ||
children = children.flat(Infinity).filter(c => c != null) | ||
if (children.length > 0) dom.childrenStrs.push(toStr(children)) | ||
@@ -56,0 +58,0 @@ return dom |
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
21354
221