@thi.ng/hdom
Advanced tools
Comparing version 5.0.7 to 5.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [5.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@5.0.7...@thi.ng/hdom@5.1.0) (2018-11-06) | ||
### Features | ||
* **hdom:** add support for dynamic user context vals ([6a3a873](https://github.com/thi-ng/umbrella/commit/6a3a873)) | ||
## [5.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@5.0.6...@thi.ng/hdom@5.0.7) (2018-10-21) | ||
@@ -8,0 +19,0 @@ |
@@ -25,3 +25,4 @@ "use strict"; | ||
if (attribs.__impl) { | ||
return attribs.__impl.createTree(opts, parent, tree, insert); | ||
return attribs.__impl | ||
.createTree(opts, parent, tree, insert); | ||
} | ||
@@ -69,3 +70,4 @@ const el = exports.createElement(parent, tag, attribs, insert); | ||
if (attribs.__impl) { | ||
return attribs.__impl.hydrateTree(opts, parent, tree, index); | ||
return attribs.__impl | ||
.hydrateTree(opts, parent, tree, index); | ||
} | ||
@@ -72,0 +74,0 @@ if (tree.__init) { |
{ | ||
"name": "@thi.ng/hdom", | ||
"version": "5.0.7", | ||
"version": "5.1.0", | ||
"description": "Lightweight vanilla ES6 UI component trees with customizable branch-local behaviors", | ||
@@ -36,3 +36,3 @@ "main": "./index.js", | ||
"@thi.ng/equiv": "^0.1.13", | ||
"@thi.ng/hiccup": "^2.4.3" | ||
"@thi.ng/hiccup": "^2.5.0" | ||
}, | ||
@@ -54,3 +54,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "5bb513915cb3c533bd4278f6f365389b3664f4d1" | ||
"gitHead": "79a6a36568719ff379a87ea445fb13f49a60690a" | ||
} |
@@ -1057,2 +1057,8 @@ # @thi.ng/hdom | ||
Any context keys with values implementing the thi.ng/api `IDeref` | ||
interface, will be automatically deref'd prior to each tree | ||
normalization / redraw. This feature can be used to define dynamic | ||
contexts linked to the main app state, e.g. using derived views provided | ||
by thi.ng/atom. | ||
```ts | ||
@@ -1059,0 +1065,0 @@ import { start } from "@thi.ng/hdom"; |
@@ -5,5 +5,4 @@ import { HDOMImplementation, HDOMOpts } from "./api"; | ||
* options as `start()`, but performs no diffing and only creates or | ||
* hydrates target once. The given tree is first normalized and no | ||
* further action will be taken, if the normalized result is `null` or | ||
* `undefined`. | ||
* hydrates target once. The given tree is first normalized and if | ||
* result is `null` or `undefined` no further action will be taken. | ||
* | ||
@@ -10,0 +9,0 @@ * @param tree |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const deref_1 = require("@thi.ng/hiccup/deref"); | ||
const default_1 = require("./default"); | ||
@@ -8,5 +9,4 @@ const utils_1 = require("./utils"); | ||
* options as `start()`, but performs no diffing and only creates or | ||
* hydrates target once. The given tree is first normalized and no | ||
* further action will be taken, if the normalized result is `null` or | ||
* `undefined`. | ||
* hydrates target once. The given tree is first normalized and if | ||
* result is `null` or `undefined` no further action will be taken. | ||
* | ||
@@ -17,4 +17,5 @@ * @param tree | ||
*/ | ||
exports.renderOnce = (tree, opts, impl = default_1.DEFAULT_IMPL) => { | ||
exports.renderOnce = (tree, opts = {}, impl = default_1.DEFAULT_IMPL) => { | ||
opts = Object.assign({ root: "app" }, opts); | ||
opts.ctx = deref_1.derefContext(opts.ctx); | ||
const root = utils_1.resolveRoot(opts.root); | ||
@@ -21,0 +22,0 @@ tree = impl.normalizeTree(opts, tree); |
@@ -10,4 +10,8 @@ import { HDOMImplementation, HDOMOpts } from "./api"; | ||
* embedded component function in the tree will receive this context | ||
* object as first argument, as will life cycle methods in component | ||
* objects. | ||
* object (shallow copy) as first argument, as will life cycle methods | ||
* in component objects. Any context keys with values implementing the | ||
* thi.ng/api `IDeref` interface, will be automatically deref'd prior to | ||
* each tree normalization / redraw. This feature can be used to define | ||
* dynamic contexts linked to the main app state, e.g. using derived | ||
* views provided by thi.ng/atom. | ||
* | ||
@@ -14,0 +18,0 @@ * **Selective updates**: No updates will be applied if the given hiccup |
26
start.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const deref_1 = require("@thi.ng/hiccup/deref"); | ||
const default_1 = require("./default"); | ||
@@ -13,4 +14,8 @@ const utils_1 = require("./utils"); | ||
* embedded component function in the tree will receive this context | ||
* object as first argument, as will life cycle methods in component | ||
* objects. | ||
* object (shallow copy) as first argument, as will life cycle methods | ||
* in component objects. Any context keys with values implementing the | ||
* thi.ng/api `IDeref` interface, will be automatically deref'd prior to | ||
* each tree normalization / redraw. This feature can be used to define | ||
* dynamic contexts linked to the main app state, e.g. using derived | ||
* views provided by thi.ng/atom. | ||
* | ||
@@ -44,17 +49,18 @@ * **Selective updates**: No updates will be applied if the given hiccup | ||
*/ | ||
exports.start = (tree, opts, impl = default_1.DEFAULT_IMPL) => { | ||
opts = Object.assign({ root: "app" }, opts); | ||
exports.start = (tree, opts = {}, impl = default_1.DEFAULT_IMPL) => { | ||
const _opts = Object.assign({ root: "app" }, opts); | ||
let prev = []; | ||
let isActive = true; | ||
const root = utils_1.resolveRoot(opts.root); | ||
const root = utils_1.resolveRoot(_opts.root); | ||
const update = () => { | ||
if (isActive) { | ||
const curr = impl.normalizeTree(opts, tree); | ||
_opts.ctx = deref_1.derefContext(opts.ctx); | ||
const curr = impl.normalizeTree(_opts, tree); | ||
if (curr != null) { | ||
if (opts.hydrate) { | ||
impl.hydrateTree(opts, root, curr); | ||
opts.hydrate = false; | ||
if (_opts.hydrate) { | ||
impl.hydrateTree(_opts, root, curr); | ||
_opts.hydrate = false; | ||
} | ||
else { | ||
impl.diffTree(opts, impl, root, prev, curr, 0); | ||
impl.diffTree(_opts, impl, root, prev, curr, 0); | ||
} | ||
@@ -61,0 +67,0 @@ prev = curr; |
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
127687
1385
1174
Updated@thi.ng/hiccup@^2.5.0