@burger-editor/frozen-patty
Advanced tools
Comparing version 0.7.3 to 0.8.0
@@ -51,1 +51,2 @@ export default class FrozenPatty { | ||
export declare type Filter = <T>(value: T) => T; | ||
//# sourceMappingURL=frozen-patty.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var get_1 = require("./get"); | ||
var set_1 = require("./set"); | ||
var get_1 = __importDefault(require("./get")); | ||
var set_1 = __importDefault(require("./set")); | ||
var FrozenPatty = /** @class */ (function () { | ||
@@ -27,3 +30,3 @@ /** | ||
var newData = Object.assign(currentData, data); | ||
this._dom = set_1.default(this._dom, newData, this._attr, this._typeConvert, this._filter); | ||
this._dom = set_1.default(this._dom, newData, this._attr, this._filter); | ||
return this; | ||
@@ -30,0 +33,0 @@ }; |
import './polyfill'; | ||
import { Filter, FrozenPattyData } from './frozen-patty'; | ||
export default function (el: Element, attr: string, typeConvert: boolean, filter?: Filter): FrozenPattyData; | ||
//# sourceMappingURL=get.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("./polyfill"); | ||
var util_1 = require("./util"); | ||
var getValue_1 = require("./getValue"); | ||
var getValue_1 = __importDefault(require("./getValue")); | ||
function default_1(el, attr, typeConvert, filter) { | ||
@@ -7,0 +10,0 @@ var filedElements = el.querySelectorAll("[data-" + attr + "]"); |
@@ -1,2 +0,2 @@ | ||
import { Filter } from './frozen-patty'; | ||
import { Filter, PrimitiveDatum } from './frozen-patty'; | ||
/** | ||
@@ -9,2 +9,3 @@ * Get value from an element | ||
*/ | ||
export default function (el: Element, attr: string, typeConvert: boolean, filter?: Filter): [string, string | number | boolean | null | undefined, boolean][]; | ||
export default function (el: Element, attr: string, typeConvert: boolean, filter?: Filter): [string | number, PrimitiveDatum, boolean][]; | ||
//# sourceMappingURL=getValue.d.ts.map |
@@ -50,3 +50,5 @@ "use strict"; | ||
else { | ||
if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement) { | ||
if (el instanceof HTMLInputElement || | ||
el instanceof HTMLSelectElement || | ||
el instanceof HTMLTextAreaElement) { | ||
var val = el.value; | ||
@@ -81,3 +83,3 @@ if (Array.isArray(val)) { | ||
else { | ||
return el.getAttribute(keyAttr) === '' || el.getAttribute(keyAttr) === 'true'; | ||
return (el.getAttribute(keyAttr) === '' || el.getAttribute(keyAttr) === 'true'); | ||
} | ||
@@ -105,4 +107,6 @@ } | ||
switch (value) { | ||
case 'true': return true; | ||
case 'false': return false; | ||
case 'true': | ||
return true; | ||
case 'false': | ||
return false; | ||
} | ||
@@ -109,0 +113,0 @@ var numeric = parseFloat(value); |
@@ -31,4 +31,5 @@ import FrozenPatty, { Filter, FrozenPattyOptions, PrimitiveDatum } from './frozen-patty'; | ||
*/ | ||
function getValue(el: Element, name: string, typeConvert?: boolean, attr?: string, filter?: Filter): string | number | boolean | (string | number | boolean | null | undefined)[] | null | undefined; | ||
function getValue(el: Element, name: string, typeConvert?: boolean, attr?: string, filter?: Filter): import("./frozen-patty").PrimitiveData; | ||
} | ||
export default frozenPatty; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var frozen_patty_1 = require("./frozen-patty"); | ||
var getValue_1 = require("./getValue"); | ||
var setValue_1 = require("./setValue"); | ||
var frozen_patty_1 = __importDefault(require("./frozen-patty")); | ||
var getValue_1 = __importDefault(require("./getValue")); | ||
var setValue_1 = __importDefault(require("./setValue")); | ||
var util_1 = require("./util"); | ||
@@ -7,0 +10,0 @@ /** |
"use strict"; | ||
if (!Element.prototype.matches) { | ||
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; | ||
Element.prototype.matches = | ||
// @ts-ignore | ||
Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; | ||
} | ||
@@ -5,0 +7,0 @@ if (!Element.prototype.closest) { |
import './polyfill'; | ||
import { Filter, FrozenPattyData } from './frozen-patty'; | ||
export default function (el: Element, data: FrozenPattyData, attr: string, typeConvert?: boolean, filter?: Filter): Element; | ||
//# sourceMappingURL=set.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("./polyfill"); | ||
var setValue_1 = require("./setValue"); | ||
function default_1(el, data, attr, typeConvert, filter) { | ||
if (typeConvert === void 0) { typeConvert = false; } | ||
var setValue_1 = __importDefault(require("./setValue")); | ||
function default_1(el, data, attr, filter) { | ||
el = el.cloneNode(true); | ||
@@ -18,19 +20,24 @@ var _loop_1 = function (dataKeyName) { | ||
} | ||
var listRoot_1 = targetEl.closest("[data-" + attr + "-list]"); | ||
if (!listRoot_1 || listRoot_1 && !listRoot_1.children.length) { | ||
var listRoot = targetEl.closest("[data-" + attr + "-list]"); | ||
if (!listRoot || (listRoot && !listRoot.children.length)) { | ||
return "continue"; | ||
} | ||
var listItem = listRoot_1.children[0].cloneNode(true); | ||
while (datum_1.length > listRoot_1.children.length) { | ||
listRoot_1.appendChild(listItem.cloneNode(true)); | ||
var listItem = listRoot.children[0].cloneNode(true); | ||
while (datum_1.length > listRoot.children.length) { | ||
listRoot.appendChild(listItem.cloneNode(true)); | ||
} | ||
var newChildren = listRoot_1.querySelectorAll(selector); | ||
var newChildren = listRoot.querySelectorAll(selector); | ||
var oldChildList_1 = Array.from(listRoot.children); | ||
var deleteNodeList_1 = []; | ||
Array.from(newChildren).forEach(function (child, i) { | ||
if (datum_1[i] != null) { | ||
setValue_1.default(dataKeyName, datum_1[i], child, attr, filter); | ||
deleteNodeList_1 = []; | ||
} | ||
else { | ||
listRoot_1.children[i].remove(); | ||
setValue_1.default(dataKeyName, '', child, attr, filter); | ||
deleteNodeList_1.push(oldChildList_1[i]); | ||
} | ||
}); | ||
deleteNodeList_1.forEach(function (node) { return node.remove(); }); | ||
} | ||
@@ -37,0 +44,0 @@ else { |
@@ -15,1 +15,2 @@ import { Filter, FrozenPattyData, PrimitiveDatum } from './frozen-patty'; | ||
export default function (name: keyof FrozenPattyData, datum: PrimitiveDatum, el: Element, attr: string, filter?: Filter): void; | ||
//# sourceMappingURL=setValue.d.ts.map |
"use strict"; | ||
// tslint:disable:max-file-line-count | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -101,7 +102,5 @@ /** | ||
else { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLSelectElement | ||
|| | ||
el instanceof HTMLTextAreaElement) { | ||
if (el instanceof HTMLInputElement || | ||
el instanceof HTMLSelectElement || | ||
el instanceof HTMLTextAreaElement) { | ||
el.value = "" + datum; | ||
@@ -221,9 +220,6 @@ } | ||
case 'autofocus': { | ||
if (el instanceof HTMLButtonElement | ||
|| | ||
el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLSelectElement | ||
|| | ||
el instanceof HTMLTextAreaElement) { | ||
if (el instanceof HTMLButtonElement || | ||
el instanceof HTMLInputElement || | ||
el instanceof HTMLSelectElement || | ||
el instanceof HTMLTextAreaElement) { | ||
el.autofocus = datum === '' ? true : !!datum; | ||
@@ -312,15 +308,9 @@ } | ||
case 'disabled': { | ||
if (el instanceof HTMLButtonElement | ||
|| | ||
el instanceof HTMLFieldSetElement | ||
|| | ||
el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLOptGroupElement | ||
|| | ||
el instanceof HTMLOptionElement | ||
|| | ||
el instanceof HTMLSelectElement | ||
|| | ||
el instanceof HTMLTextAreaElement) { | ||
if (el instanceof HTMLButtonElement || | ||
el instanceof HTMLFieldSetElement || | ||
el instanceof HTMLInputElement || | ||
el instanceof HTMLOptGroupElement || | ||
el instanceof HTMLOptionElement || | ||
el instanceof HTMLSelectElement || | ||
el instanceof HTMLTextAreaElement) { | ||
el.disabled = datum === '' ? true : !!datum; | ||
@@ -396,7 +386,5 @@ } | ||
case 'max': { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLMeterElement | ||
|| | ||
el instanceof HTMLProgressElement) { | ||
if (el instanceof HTMLInputElement || | ||
el instanceof HTMLMeterElement || | ||
el instanceof HTMLProgressElement) { | ||
var max = toInt(datum); | ||
@@ -416,5 +404,3 @@ if (isNaN(max)) { | ||
case 'maxlength': { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLTextAreaElement) { | ||
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) { | ||
var maxLength = toInt(datum); | ||
@@ -434,5 +420,3 @@ if (isNaN(maxLength)) { | ||
case 'min': { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLMeterElement) { | ||
if (el instanceof HTMLInputElement || el instanceof HTMLMeterElement) { | ||
var min = toInt(datum); | ||
@@ -452,5 +436,3 @@ if (isNaN(min)) { | ||
case 'multiple': { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLSelectElement) { | ||
if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement) { | ||
el.multiple = datum === '' ? true : !!datum; | ||
@@ -506,5 +488,3 @@ } | ||
case 'readonly': { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLTextAreaElement) { | ||
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) { | ||
el.readOnly = datum === '' ? true : !!datum; | ||
@@ -518,7 +498,5 @@ } | ||
case 'required': { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLSelectElement | ||
|| | ||
el instanceof HTMLTextAreaElement) { | ||
if (el instanceof HTMLInputElement || | ||
el instanceof HTMLSelectElement || | ||
el instanceof HTMLTextAreaElement) { | ||
el.required = datum === '' ? true : !!datum; | ||
@@ -572,5 +550,3 @@ } | ||
case 'size': { | ||
if (el instanceof HTMLInputElement | ||
|| | ||
el instanceof HTMLSelectElement) { | ||
if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement) { | ||
var size = toInt(datum); | ||
@@ -639,7 +615,5 @@ if (isNaN(size)) { | ||
case 'target': { | ||
if (el instanceof HTMLAnchorElement | ||
|| | ||
el instanceof HTMLAreaElement | ||
|| | ||
el instanceof HTMLFormElement) { | ||
if (el instanceof HTMLAnchorElement || | ||
el instanceof HTMLAreaElement || | ||
el instanceof HTMLFormElement) { | ||
if (datum) { | ||
@@ -646,0 +620,0 @@ el.target = "" + datum; |
@@ -6,3 +6,4 @@ import { FrozenPattyData, PrimitiveDatum } from './frozen-patty'; | ||
export declare function arrayToHash(kvs: [keyof FrozenPattyData, PrimitiveDatum, boolean][]): { | ||
[index: string]: string | number | boolean | (string | number | boolean | null | undefined)[] | null | undefined; | ||
[index: string]: import("./frozen-patty").PrimitiveData; | ||
}; | ||
//# sourceMappingURL=util.d.ts.map |
{ | ||
"name": "@burger-editor/frozen-patty", | ||
"version": "0.7.3", | ||
"description": "Pure HTML to JSON converter that not use template engine.", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"author": "Yusuke Hirao", | ||
"license": "MIT", | ||
"private": false, | ||
"repository": { | ||
"url": "git@github.com:YusukeHirao/frozen-patty.git" | ||
}, | ||
"scripts": { | ||
"start": "node ./", | ||
"build": "gulp", | ||
"dev": "gulp watch", | ||
"test": "nyc ava && nyc report --reporter=html", | ||
"coveralls": "nyc ava && nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"ava": { | ||
"require": [ | ||
"./helper/setup-browser-env.js" | ||
] | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.25.0", | ||
"browser-env": "^3.2.5", | ||
"coveralls": "^3.0.1", | ||
"del": "^3.0.0", | ||
"eslint": "^4.19.1", | ||
"gulp": "^3.9.1", | ||
"gulp-ava": "^0.19.0", | ||
"gulp-typescript": "^4.0.2", | ||
"nyc": "^11.8.0", | ||
"run-sequence": "^2.2.1", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.8.3" | ||
} | ||
"name": "@burger-editor/frozen-patty", | ||
"version": "0.8.0", | ||
"description": "Pure HTML to JSON converter that not use template engine.", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"author": "Yusuke Hirao", | ||
"license": "MIT", | ||
"private": false, | ||
"repository": { | ||
"url": "git@github.com:YusukeHirao/frozen-patty.git" | ||
}, | ||
"scripts": { | ||
"start": "node ./", | ||
"build": "gulp", | ||
"dev": "gulp watch", | ||
"test": "nyc ava && nyc report --reporter=html", | ||
"coveralls": "nyc ava && nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"ava": { | ||
"require": [ | ||
"./helper/setup-browser-env.js" | ||
] | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.25.0", | ||
"browser-env": "^3.2.5", | ||
"coveralls": "^3.0.2", | ||
"del": "^3.0.0", | ||
"eslint": "^5.6.1", | ||
"eslint-plugin-prettier": "3.0.0", | ||
"gulp": "^3.9.1", | ||
"gulp-ava": "^0.19.0", | ||
"gulp-typescript": "^5.0.0-alpha.3", | ||
"nyc": "^13.0.1", | ||
"prettier": "^1.14.3", | ||
"prettier-eslint": "8.8.2", | ||
"run-sequence": "^2.2.1", | ||
"tslint": "^5.11.0", | ||
"tslint-config-prettier": "^1.15.0", | ||
"tslint-plugin-prettier": "^2.0.0", | ||
"typescript": "^3.1.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
23
42485
17
1179