fix(state): 修复 keyed nodes 重排时缺少 insertBefore,降级 structuredClone 为 JSON 序列化(by AI)

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>
This commit is contained in:
AI Engineer 2026-06-22 19:23:22 +08:00
parent d416907774
commit cc4e5226c0
5 changed files with 7 additions and 5 deletions

3
dist/state.js vendored
View File

@ -4,7 +4,7 @@
"use strict";
var _a, _b;
const Util = {
clone: globalThis.structuredClone || ((obj) => JSON.parse(JSON.stringify(obj))),
clone: (obj) => JSON.parse(JSON.stringify(obj)),
base64: (str) => btoa(String.fromCharCode(...new TextEncoder().encode(str))),
unbase64: (str) => new TextDecoder().decode(Uint8Array.from(atob(str), (c) => c.charCodeAt(0))),
urlbase64: (str) => Util.base64(str).replace(/[+/=]/g, (m) => ({ "+": "-", "/": "", "=": "" })[m]),
@ -385,6 +385,7 @@
if (existingNodes) {
node._keyedNodes.delete(keyVal);
existingNodes.forEach((child) => {
node.parentNode.insertBefore(child, node);
child._ref[indexName] = k;
child._ref[asName] = item;
_scanTree(child);

2
dist/state.min.js vendored

File diff suppressed because one or more lines are too long

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@apigo.cc/state",
"version": "1.0.19",
"version": "1.0.20",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@apigo.cc/state",
"version": "1.0.19",
"version": "1.0.20",
"devDependencies": {
"@playwright/test": "^1.40.0",
"@rollup/plugin-terser": "^1.0.0",

View File

@ -213,6 +213,7 @@ export function _updateBinding(binding) {
if (existingNodes) {
node._keyedNodes.delete(keyVal);
existingNodes.forEach(child => {
node.parentNode.insertBefore(child, node);
child._ref[indexName] = k;
child._ref[asName] = item;
_scanTree(child);

View File

@ -4,7 +4,7 @@
*/
export const Util = {
clone: globalThis.structuredClone || (obj => JSON.parse(JSON.stringify(obj))),
clone: obj => JSON.parse(JSON.stringify(obj)),
base64: str => btoa(String.fromCharCode(...new TextEncoder().encode(str))),
unbase64: str => new TextDecoder().decode(Uint8Array.from(atob(str), c => c.charCodeAt(0))),
urlbase64: str => Util.base64(str).replace(/[+/=]/g, m => ({ '+': '-', '/': '', '=': '' }[m])),