haori 0.41.3 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +4 -2
- package/README.md +4 -2
- package/dist/haori.cjs.js +13 -13
- package/dist/haori.es.js +843 -573
- package/dist/haori.iife.js +13 -13
- package/dist/index.d.ts +139 -3
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Haori.js は、HTML 属性を中心にして動的な UI を実現する軽量なライブラリです。JavaScript をほとんど書かずに、データバインディング、条件分岐、繰り返し処理、フォームの双方向バインディング、サーバー通信などを HTML 属性で宣言できます。
|
|
4
4
|
|
|
5
|
-
バージョン: 0.
|
|
5
|
+
バージョン: 0.42.0
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -143,7 +143,9 @@ Haori.mount(document.body, {items: [{name: 'りんご'}, {name: 'みかん'}]});
|
|
|
143
143
|
|
|
144
144
|
JS からバインドデータを読むには `Haori.Core.getBindingData(element, {resolved?})` を使います。既定では要素自身の生バインドデータ(無ければ `null`)、`resolved: true` で継承を解決済みのスコープを返します(`setBindingData` の対となる読み取り API)。
|
|
145
145
|
|
|
146
|
-
テンプレート式では、プロパティアクセス、動的インデックスを含むブラケットアクセス、optional chaining、三項演算子、配列 `map` / `filter` のアロー関数、spread
|
|
146
|
+
テンプレート式では、プロパティアクセス、動的インデックスを含むブラケットアクセス、optional chaining、三項演算子、配列 `map` / `filter` のアロー関数、spread を伴う呼び出しなどの構文を利用できます。一方で、グローバルオブジェクト、`eval` や `arguments`、`constructor`、`__proto__`、`prototype`、`Reflect`、`Object` などの脱出経路は遮断されます(計算プロパティ名で組み立てた場合も評価時に遮断します)。`Object` がブロックされるため、`Object.assign` の代わりにスプレッド構文 `{...a, ...b}` を使ってください。ブロックされた識別子を式で参照すると、コンソールに `blocked identifier(s): …` という警告が出力されます。
|
|
147
|
+
|
|
148
|
+
> **セキュリティの前提**: 式のテキストは**開発者が書くコード**です。上記の遮断は事故を難しくする多層防御であり、悪意ある式を防ぐ境界ではありません(式は最終的に `new Function` で評価されます)。**利用者入力や API 応答を式のテキストへ差し込まないでください。** HTML エスケープは式のエスケープではありません(`'` は属性値を読む時点で `'` に戻るため、文字列リテラルの外へ出られます)。信頼できない値は `data-bind` の**値**として渡し、式からはキーで参照してください。詳細は [docs/ja/specs.md](docs/ja/specs.md) の「XSS対策」を参照してください。
|
|
147
149
|
|
|
148
150
|
テスト・デバッグ補助: `waitForRenders()`(`Haori.waitForRenders()` でも可)は、初期化・進行中のフェッチ・キューに積まれた描画タスクがすべて落ち着くまで待機します(E2E テストで描画完了を待つのに便利)。`Haori.Core.dumpScope(element)` は要素に解決されるスコープ(`resolved`)と各キーの由来(`sources`)を返します。開発モードでは falsy な `data-if` がその式と参照スコープを自動でログ出力します。
|
|
149
151
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Haori.js is a lightweight, HTML-first UI library that enables dynamic user interfaces primarily through HTML attributes. It lets you declare data bindings, conditional rendering, list rendering, form two-way binding, server fetches, and HTML imports without writing much JavaScript.
|
|
4
4
|
|
|
5
|
-
Version: 0.
|
|
5
|
+
Version: 0.42.0
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -145,7 +145,9 @@ To read binding data from JS, use `Haori.Core.getBindingData(element, {resolved?
|
|
|
145
145
|
|
|
146
146
|
To write it, use `Haori.Core.setBindingData(element, data, options?)`. The call is treated as an explicit supply of values: it wins over edits made before the call and loses to edits made after it. If another library rewrote `data-bind` just before the call, that rewrite is ordered first, so **your value is the one that remains**. The optional third argument covers advanced cases (`kind`, `sequence`, `editedPaths`, `clearUserEdits`, `skipFragments`, `reentrant`, `reflectToAttribute`) and is not needed for normal use.
|
|
147
147
|
|
|
148
|
-
Template expressions support
|
|
148
|
+
Template expressions support JavaScript-like syntax such as property access, bracket access with dynamic indexes, optional chaining, ternary expressions, and method chains including array `map`/`filter` with arrow functions and spread calls. Access to global objects, `eval` or `arguments`, and prototype escape paths such as `constructor`, `__proto__`, `prototype`, `Reflect`, or `Object` is blocked — including names assembled at runtime in a computed property, which are checked when the key is evaluated. Because `Object` is blocked, use spread syntax `{...a, ...b}` instead of `Object.assign`; when a blocked identifier is referenced in an expression, a `blocked identifier(s): …` warning is logged to the console.
|
|
149
|
+
|
|
150
|
+
> **Security model:** expression text is **code you write**. The blocks above are defense in depth that make accidents harder, not a boundary against malicious expressions (expressions are ultimately evaluated with `new Function`). **Never interpolate user input or API responses into expression text.** HTML escaping is not expression escaping — `'` turns back into `'` when the attribute value is parsed, which escapes the string literal. Pass untrusted data as `data-bind` **values** and reference it by key from expressions. See "XSS対策" in [docs/ja/specs.md](docs/ja/specs.md) for details.
|
|
149
151
|
|
|
150
152
|
Helpers for tests and debugging: `waitForRenders()` (also `Haori.waitForRenders()`) resolves once initialization, in-flight fetches, and queued render tasks have all settled — useful for E2E tests. `Haori.Core.dumpScope(element)` returns the scope resolved for an element (`resolved`) and where each key comes from (`sources`); in dev mode a falsy `data-if` also logs its expression and referenced scope automatically.
|
|
151
153
|
|