Comparing version 3.3.1 to 3.4.0
export { DOMAPI, htmlDomApi } from "./htmldomapi"; | ||
export { init } from "./init"; | ||
export { init, Options } from "./init"; | ||
export { ThunkData, Thunk, ThunkFn, thunk } from "./thunk"; | ||
@@ -4,0 +4,0 @@ export { Key, VNode, VNodeData, vnode } from "./vnode"; |
import { Module } from "./modules/module"; | ||
import { VNode } from "./vnode"; | ||
import { DOMAPI } from "./htmldomapi"; | ||
declare type Options = { | ||
export declare type Options = { | ||
experimental?: { | ||
@@ -10,2 +10,1 @@ fragments?: boolean; | ||
export declare function init(modules: Array<Partial<Module>>, domApi?: DOMAPI, options?: Options): (oldVnode: VNode | Element | DocumentFragment, vnode: VNode) => VNode; | ||
export {}; |
export const array = Array.isArray; | ||
export function primitive(s) { | ||
return typeof s === "string" || | ||
return (typeof s === "string" || | ||
typeof s === "number" || | ||
s instanceof String || | ||
s instanceof Number; | ||
s instanceof Number); | ||
} | ||
//# sourceMappingURL=is.js.map |
@@ -83,6 +83,6 @@ 'use strict'; | ||
function primitive(s) { | ||
return typeof s === "string" || | ||
return (typeof s === "string" || | ||
typeof s === "number" || | ||
s instanceof String || | ||
s instanceof Number; | ||
s instanceof Number); | ||
} | ||
@@ -640,2 +640,4 @@ | ||
const attrs = {}; | ||
const datasets = {}; | ||
const data = {}; | ||
const children = []; | ||
@@ -648,3 +650,10 @@ let name; | ||
name = elmAttrs[i].nodeName; | ||
if (name !== "id" && name !== "class") { | ||
if (name[0] === "d" && | ||
name[1] === "a" && | ||
name[2] === "t" && | ||
name[3] === "a" && | ||
name[4] === "-") { | ||
datasets[name.slice(5)] = elmAttrs[i].nodeValue || ""; | ||
} | ||
else if (name !== "id" && name !== "class") { | ||
attrs[name] = elmAttrs[i].nodeValue; | ||
@@ -656,3 +665,6 @@ } | ||
} | ||
const data = { attrs }; | ||
if (Object.keys(attrs).length > 0) | ||
data.attrs = attrs; | ||
if (Object.keys(datasets).length > 0) | ||
data.datasets = datasets; | ||
if (sel[0] === "s" && | ||
@@ -659,0 +671,0 @@ sel[1] === "v" && |
@@ -13,2 +13,4 @@ import { addNS } from "./h"; | ||
const attrs = {}; | ||
const datasets = {}; | ||
const data = {}; | ||
const children = []; | ||
@@ -21,3 +23,10 @@ let name; | ||
name = elmAttrs[i].nodeName; | ||
if (name !== "id" && name !== "class") { | ||
if (name[0] === "d" && | ||
name[1] === "a" && | ||
name[2] === "t" && | ||
name[3] === "a" && | ||
name[4] === "-") { | ||
datasets[name.slice(5)] = elmAttrs[i].nodeValue || ""; | ||
} | ||
else if (name !== "id" && name !== "class") { | ||
attrs[name] = elmAttrs[i].nodeValue; | ||
@@ -29,3 +38,6 @@ } | ||
} | ||
const data = { attrs }; | ||
if (Object.keys(attrs).length > 0) | ||
data.attrs = attrs; | ||
if (Object.keys(datasets).length > 0) | ||
data.datasets = datasets; | ||
if (sel[0] === "s" && | ||
@@ -32,0 +44,0 @@ sel[1] === "v" && |
@@ -1,8 +0,20 @@ | ||
## [3.3.1](https://github.com/snabbdom/snabbdom/compare/v3.3.0...v3.3.1) (2022-01-18) | ||
# [3.4.0](https://github.com/snabbdom/snabbdom/compare/v3.3.1...v3.4.0) (2022-03-20) | ||
### Bug Fixes | ||
* ensure SVG namespaces are added to nodes ([#996](https://github.com/snabbdom/snabbdom/issues/996)) ([f89f085](https://github.com/snabbdom/snabbdom/commit/f89f085f558baf6a41b43ffa50c9b5b1b1c6b034)), closes [#388](https://github.com/snabbdom/snabbdom/issues/388) [#867](https://github.com/snabbdom/snabbdom/issues/867) | ||
* use array access instead of string.startsWith ([515bc97](https://github.com/snabbdom/snabbdom/commit/515bc97c27239521c516e403d975117ad268ba6b)) | ||
### Features | ||
* export `Options` type ([#1005](https://github.com/snabbdom/snabbdom/issues/1005)) ([dca0b0c](https://github.com/snabbdom/snabbdom/commit/dca0b0c9af5ff514b26ca684c2c75b11733c2418)) | ||
* toVnode is support dataset ([#1008](https://github.com/snabbdom/snabbdom/issues/1008)) ([47ef5c1](https://github.com/snabbdom/snabbdom/commit/47ef5c14e92c15fde7d018a94fa2c6dad2a1a342)), closes [#976](https://github.com/snabbdom/snabbdom/issues/976)## [3.3.1](https://github.com/snabbdom/snabbdom/compare/v3.3.0...v3.3.1) (2022-01-18) | ||
### Bug Fixes | ||
- ensure SVG namespaces are added to nodes ([#996](https://github.com/snabbdom/snabbdom/issues/996)) ([f89f085](https://github.com/snabbdom/snabbdom/commit/f89f085f558baf6a41b43ffa50c9b5b1b1c6b034)), closes [#388](https://github.com/snabbdom/snabbdom/issues/388) [#867](https://github.com/snabbdom/snabbdom/issues/867) | ||
# [3.3.0](https://github.com/snabbdom/snabbdom/compare/v3.2.0...v3.3.0) (2022-01-17) | ||
@@ -375,2 +387,2 @@ | ||
[v0.6.1]: https://github.com/snabbdom/snabbdom/compare/v0.6.0...v0.6.1 | ||
[v0.6.0]: https://github.com/snabbdom/snabbdom/compare/v0.5.0...v0.6.0 | ||
[v0.6.0]: https://github.com/snabbdom/snabbdom/compare/v0.5.0...v0.6.0 |
@@ -27,4 +27,3 @@ import { | ||
title: "The Shawshank Redemption", | ||
desc: | ||
"Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.", | ||
desc: "Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.", | ||
elmHeight: 0, | ||
@@ -35,4 +34,3 @@ }, | ||
title: "The Godfather", | ||
desc: | ||
"The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son.", | ||
desc: "The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son.", | ||
elmHeight: 0, | ||
@@ -43,4 +41,3 @@ }, | ||
title: "The Godfather: Part II", | ||
desc: | ||
"The early life and career of Vito Corleone in 1920s New York is portrayed while his son, Michael, expands and tightens his grip on his crime syndicate stretching from Lake Tahoe, Nevada to pre-revolution 1958 Cuba.", | ||
desc: "The early life and career of Vito Corleone in 1920s New York is portrayed while his son, Michael, expands and tightens his grip on his crime syndicate stretching from Lake Tahoe, Nevada to pre-revolution 1958 Cuba.", | ||
elmHeight: 0, | ||
@@ -51,4 +48,3 @@ }, | ||
title: "The Dark Knight", | ||
desc: | ||
"When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.", | ||
desc: "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.", | ||
elmHeight: 0, | ||
@@ -59,4 +55,3 @@ }, | ||
title: "Pulp Fiction", | ||
desc: | ||
"The lives of two mob hit men, a boxer, a gangster's wife, and a pair of diner bandits intertwine in four tales of violence and redemption.", | ||
desc: "The lives of two mob hit men, a boxer, a gangster's wife, and a pair of diner bandits intertwine in four tales of violence and redemption.", | ||
elmHeight: 0, | ||
@@ -67,4 +62,3 @@ }, | ||
title: "Schindler's List", | ||
desc: | ||
"In Poland during World War II, Oskar Schindler gradually becomes concerned for his Jewish workforce after witnessing their persecution by the Nazis.", | ||
desc: "In Poland during World War II, Oskar Schindler gradually becomes concerned for his Jewish workforce after witnessing their persecution by the Nazis.", | ||
elmHeight: 0, | ||
@@ -75,4 +69,3 @@ }, | ||
title: "12 Angry Men", | ||
desc: | ||
"A dissenting juror in a murder trial slowly manages to convince the others that the case is not as obviously clear as it seemed in court.", | ||
desc: "A dissenting juror in a murder trial slowly manages to convince the others that the case is not as obviously clear as it seemed in court.", | ||
elmHeight: 0, | ||
@@ -83,4 +76,3 @@ }, | ||
title: "The Good, the Bad and the Ugly", | ||
desc: | ||
"A bounty hunting scam joins two men in an uneasy alliance against a third in a race to find a fortune in gold buried in a remote cemetery.", | ||
desc: "A bounty hunting scam joins two men in an uneasy alliance against a third in a race to find a fortune in gold buried in a remote cemetery.", | ||
elmHeight: 0, | ||
@@ -91,4 +83,3 @@ }, | ||
title: "The Lord of the Rings: The Return of the King", | ||
desc: | ||
"Gandalf and Aragorn lead the World of Men against Sauron's army to draw his gaze from Frodo and Sam as they approach Mount Doom with the One Ring.", | ||
desc: "Gandalf and Aragorn lead the World of Men against Sauron's army to draw his gaze from Frodo and Sam as they approach Mount Doom with the One Ring.", | ||
elmHeight: 0, | ||
@@ -99,4 +90,3 @@ }, | ||
title: "Fight Club", | ||
desc: | ||
"An insomniac office worker looking for a way to change his life crosses paths with a devil-may-care soap maker and they form an underground fight club that evolves into something much, much more...", | ||
desc: "An insomniac office worker looking for a way to change his life crosses paths with a devil-may-care soap maker and they form an underground fight club that evolves into something much, much more...", | ||
elmHeight: 0, | ||
@@ -103,0 +93,0 @@ }, |
{ | ||
"name": "snabbdom", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"description": "A virtual DOM library with focus on simplicity, modularity, powerful features and performance.", | ||
@@ -42,14 +42,14 @@ "homepage": "https://github.com/snabbdom/snabbdom#readme", | ||
"devDependencies": { | ||
"@release-it/conventional-changelog": "^4.1.0", | ||
"@release-it/conventional-changelog": "^4.2.2", | ||
"@types/chai": "4.3.0", | ||
"@types/lodash.shuffle": "4.2.6", | ||
"@types/mocha": "9.0.0", | ||
"@typescript-eslint/eslint-plugin": "5.10.0", | ||
"@typescript-eslint/parser": "^5.10.0", | ||
"chai": "4.3.4", | ||
"@types/mocha": "9.1.0", | ||
"@typescript-eslint/eslint-plugin": "5.15.0", | ||
"@typescript-eslint/parser": "^5.15.0", | ||
"chai": "4.3.6", | ||
"commithelper": "^1.2.0", | ||
"conventional-changelog-angular": "^5.0.13", | ||
"cross-env": "7.0.3", | ||
"eslint": "8.7.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint": "8.11.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "2.25.4", | ||
@@ -59,5 +59,5 @@ "eslint-plugin-markdown": "2.2.1", | ||
"husky": "7.0.4", | ||
"karma": "6.3.11", | ||
"karma": "6.3.17", | ||
"karma-browserstack-launcher": "1.6.0", | ||
"karma-chrome-launcher": "3.1.0", | ||
"karma-chrome-launcher": "3.1.1", | ||
"karma-firefox-launcher": "2.1.2", | ||
@@ -67,10 +67,10 @@ "karma-mocha": "2.0.1", | ||
"karma-typescript": "^5.5.3", | ||
"lint-staged": "^12.1.7", | ||
"lint-staged": "^12.3.7", | ||
"lodash.shuffle": "4.2.0", | ||
"mocha": "9.1.4", | ||
"prettier": "^2.5.1", | ||
"release-it": "^14.12.3", | ||
"rollup": "^2.64.0", | ||
"mocha": "9.2.2", | ||
"prettier": "^2.6.0", | ||
"release-it": "^14.13.0", | ||
"rollup": "^2.70.1", | ||
"serve": "^13.0.2", | ||
"typescript": "4.5.4" | ||
"typescript": "4.6.2" | ||
}, | ||
@@ -77,0 +77,0 @@ "prettier": {}, |
@@ -9,3 +9,3 @@ <img alt="Snabbdom" src="readme-title.svg" width="356px"> | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) | ||
[![Build Status](https://travis-ci.org/snabbdom/snabbdom.svg?branch=master)](https://travis-ci.org/snabbdom/snabbdom) | ||
[![Build Status](https://github.com/snabbdom/snabbdom/actions/workflows/steps.yml/badge.svg)](https://github.com/snabbdom/snabbdom/actions/workflows/steps.yml) | ||
[![npm version](https://badge.fury.io/js/snabbdom.svg)](https://badge.fury.io/js/snabbdom) | ||
@@ -22,2 +22,4 @@ [![npm downloads](https://img.shields.io/npm/dm/snabbdom.svg)](https://www.npmjs.com/package/snabbdom) | ||
English | [简体中文](./README-zh_CN.md) | ||
## Introduction | ||
@@ -24,0 +26,0 @@ |
{ | ||
"redirects": [ | ||
{ "source": "/", "destination": "/examples" } | ||
], | ||
"redirects": [{ "source": "/", "destination": "/examples" }], | ||
"rewrites": [ | ||
{ "source": "build/:file", "destination": "build/:file.js" }, | ||
{ "source": "build/helpers/:file", "destination": "build/helpers/:file.js" }, | ||
{ | ||
"source": "build/helpers/:file", | ||
"destination": "build/helpers/:file.js" | ||
}, | ||
{ "source": "build/modules/:file", "destination": "build/modules/:file.js" } | ||
] | ||
} |
// core | ||
export { DOMAPI, htmlDomApi } from "./htmldomapi"; | ||
export { init } from "./init"; | ||
export { init, Options } from "./init"; | ||
export { ThunkData, Thunk, ThunkFn, thunk } from "./thunk"; | ||
@@ -5,0 +5,0 @@ export { Key, VNode, VNodeData, vnode } from "./vnode"; |
@@ -81,3 +81,3 @@ import { Module } from "./modules/module"; | ||
// TODO Should `domApi` be put into this in the next major version bump? | ||
type Options = { | ||
export type Options = { | ||
experimental?: { | ||
@@ -84,0 +84,0 @@ fragments?: boolean; |
export const array = Array.isArray; | ||
export function primitive(s: any): s is string | number { | ||
return typeof s === "string" || | ||
return ( | ||
typeof s === "string" || | ||
typeof s === "number" || | ||
s instanceof String || | ||
s instanceof Number; | ||
s instanceof Number | ||
); | ||
} |
@@ -14,2 +14,5 @@ import { addNS } from "./h"; | ||
const attrs: any = {}; | ||
const datasets: Record<string, string> = {}; | ||
const data: Record<string, any> = {}; | ||
const children: VNode[] = []; | ||
@@ -22,3 +25,11 @@ let name: string; | ||
name = elmAttrs[i].nodeName; | ||
if (name !== "id" && name !== "class") { | ||
if ( | ||
name[0] === "d" && | ||
name[1] === "a" && | ||
name[2] === "t" && | ||
name[3] === "a" && | ||
name[4] === "-" | ||
) { | ||
datasets[name.slice(5)] = elmAttrs[i].nodeValue || ""; | ||
} else if (name !== "id" && name !== "class") { | ||
attrs[name] = elmAttrs[i].nodeValue; | ||
@@ -30,3 +41,6 @@ } | ||
} | ||
const data = { attrs }; | ||
if (Object.keys(attrs).length > 0) data.attrs = attrs; | ||
if (Object.keys(datasets).length > 0) data.datasets = datasets; | ||
if ( | ||
@@ -33,0 +47,0 @@ sel[0] === "s" && |
@@ -552,5 +552,29 @@ import { assert } from "chai"; | ||
assert.strictEqual(children[0].sel, "x-h2#hx"); | ||
assert.deepEqual(children[0].data, { attrs: { "data-env": "xyz" } }); | ||
assert.deepEqual(children[0].data, { datasets: { env: "xyz" } }); | ||
assert.strictEqual(children[1].text, "Foobar"); | ||
}); | ||
it("can parsing datasets and attrs", function () { | ||
const onlyAttrs = document.createElement("div"); | ||
onlyAttrs.setAttribute("foo", "bar"); | ||
assert.deepEqual(toVNode(onlyAttrs).data, { attrs: { foo: "bar" } }); | ||
const onlyDatasets = document.createElement("div"); | ||
onlyDatasets.setAttribute("data-foo", "bar"); | ||
assert.deepEqual(toVNode(onlyDatasets).data, { | ||
datasets: { foo: "bar" }, | ||
}); | ||
const onlyDatasets2 = document.createElement("div"); | ||
onlyDatasets2.dataset.foo = "bar"; | ||
assert.deepEqual(toVNode(onlyDatasets2).data, { | ||
datasets: { foo: "bar" }, | ||
}); | ||
const bothAttrsAndDatasets = document.createElement("div"); | ||
bothAttrsAndDatasets.setAttribute("foo", "bar"); | ||
bothAttrsAndDatasets.setAttribute("data-foo", "bar"); | ||
bothAttrsAndDatasets.dataset.again = "again"; | ||
assert.deepEqual(toVNode(bothAttrsAndDatasets).data, { | ||
attrs: { foo: "bar" }, | ||
datasets: { foo: "bar", again: "again" }, | ||
}); | ||
}); | ||
}); | ||
@@ -557,0 +581,0 @@ describe("updating children with keys", function () { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
417531
117
7770
1027