@burger-editor/frozen-patty
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -14,3 +14,3 @@ export default class FrozenPatty { | ||
toHTML(): string; | ||
toDOM(): HTMLElement; | ||
toDOM(): Element; | ||
} | ||
@@ -41,3 +41,3 @@ export interface FrozenPattyOptions { | ||
} | ||
export declare type PrimitiveDatum = string | number | boolean; | ||
export declare type PrimitiveDatum = string | number | boolean | null | undefined; | ||
export declare type PrimitiveData = PrimitiveDatum | PrimitiveDatum[]; |
import { FrozenPattyData } from './frozen-patty'; | ||
import './polyfill'; | ||
export declare function imports(el: HTMLElement, data: FrozenPattyData, attr: string, typeConvert?: boolean): HTMLElement; | ||
export declare function imports(el: Element, data: FrozenPattyData, attr: string, typeConvert?: boolean): Element; |
@@ -28,3 +28,3 @@ "use strict"; | ||
if (datum_1[i] != null) { | ||
datumToElement(dataKeyName, datum_1[i] || '', child, attr); | ||
datumToElement(dataKeyName, datum_1[i], child, attr); | ||
} | ||
@@ -128,3 +128,3 @@ else { | ||
// SVGElement or more | ||
el.setAttribute(attr, "" + datum); | ||
el.setAttribute(targetAttr, "" + datum); | ||
} | ||
@@ -159,2 +159,6 @@ // | ||
function setAttribute(el, attr, datum) { | ||
if (datum == null) { | ||
el.removeAttribute(attr); | ||
return; | ||
} | ||
switch (attr) { | ||
@@ -727,8 +731,3 @@ // ⚠️ Dosen't test | ||
default: { | ||
if (datum == null) { | ||
el.removeAttribute(attr); | ||
} | ||
else { | ||
el.setAttribute(attr, "" + datum); | ||
} | ||
el.setAttribute(attr, "" + datum); | ||
} | ||
@@ -735,0 +734,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { FrozenPattyData, PrimitiveDatum } from './frozen-patty'; | ||
import { FrozenPattyData } from './frozen-patty'; | ||
import './polyfill'; | ||
export declare function toJSON(el: HTMLElement, attr: string, typeConvert: boolean): FrozenPattyData; | ||
export declare function toJSON(el: Element, attr: string, typeConvert: boolean): FrozenPattyData; | ||
/** | ||
@@ -9,2 +9,2 @@ * | ||
*/ | ||
export declare function extractor(el: HTMLElement, attr: string, typeConvert: boolean): [string, PrimitiveDatum, boolean][]; | ||
export declare function extractor(el: Element, attr: string, typeConvert: boolean): [string, string | number | boolean | null | undefined, boolean][]; |
@@ -85,3 +85,8 @@ "use strict"; | ||
case 'contenteditable': { | ||
return el.contentEditable === '' || el.contentEditable === 'true'; | ||
if (el instanceof HTMLElement) { | ||
return el.contentEditable === '' || el.contentEditable === 'true'; | ||
} | ||
else { | ||
return el.getAttribute(keyAttr) === '' || el.getAttribute(keyAttr) === 'true'; | ||
} | ||
} | ||
@@ -88,0 +93,0 @@ case 'checked': { |
{ | ||
"name": "@burger-editor/frozen-patty", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Pure HTML to JSON converter that not use template engine.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
273261
1473