release: v1.0.15 By: AICoder

This commit is contained in:
AI Engineer 2026-06-05 19:17:54 +08:00
parent a777f315b4
commit f1397a4776
8 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,10 @@
# CHANGELOG # CHANGELOG
## v1.0.15 (2026-06-05)
### 修复
- **挂载节点绑定失效**: 修复了在离线/内存中提早调用 `_scanTree` 时子节点被打上 `_stScanned` 标记,导致节点被真正挂载(`isConnected`)时因 `_stScanned` 为真而被 MutationObserver 跳过,从而使其上的表达式绑定未被计算的 Bug。现在只有当节点真正 connected 时才记录 `_stScanned = true`
## v1.0.14 (2026-06-05) ## v1.0.14 (2026-06-05)
### 修复 ### 修复

3
dist/state.js vendored
View File

@ -477,7 +477,7 @@
return; return;
} }
if (node.nodeType !== 1) return; if (node.nodeType !== 1) return;
node._stScanned = true; if (node.isConnected) node._stScanned = true;
if (!node._stTranslated) { if (!node._stTranslated) {
Array.from(node.attributes).forEach((attr) => { Array.from(node.attributes).forEach((attr) => {
if (!attr.name.startsWith("$") && !attr.name.startsWith("st-") && !attr.name.startsWith(".")) { if (!attr.name.startsWith("$") && !attr.name.startsWith("st-") && !attr.name.startsWith(".")) {
@ -697,7 +697,6 @@
mutations.forEach((mutation) => { mutations.forEach((mutation) => {
mutation.addedNodes.forEach((newNode) => { mutation.addedNodes.forEach((newNode) => {
if (newNode.isConnected && newNode.nodeType === 1 && !newNode._stScanned) { if (newNode.isConnected && newNode.nodeType === 1 && !newNode._stScanned) {
newNode._stScanned = true;
_scanTree(newNode); _scanTree(newNode);
} }
}); });

2
dist/state.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/state.min.mjs vendored

File diff suppressed because one or more lines are too long

3
dist/state.mjs vendored
View File

@ -473,7 +473,7 @@ const _scanTree = (node, scanObj = {}) => {
return; return;
} }
if (node.nodeType !== 1) return; if (node.nodeType !== 1) return;
node._stScanned = true; if (node.isConnected) node._stScanned = true;
if (!node._stTranslated) { if (!node._stTranslated) {
Array.from(node.attributes).forEach((attr) => { Array.from(node.attributes).forEach((attr) => {
if (!attr.name.startsWith("$") && !attr.name.startsWith("st-") && !attr.name.startsWith(".")) { if (!attr.name.startsWith("$") && !attr.name.startsWith("st-") && !attr.name.startsWith(".")) {
@ -693,7 +693,6 @@ if (typeof document !== "undefined") {
mutations.forEach((mutation) => { mutations.forEach((mutation) => {
mutation.addedNodes.forEach((newNode) => { mutation.addedNodes.forEach((newNode) => {
if (newNode.isConnected && newNode.nodeType === 1 && !newNode._stScanned) { if (newNode.isConnected && newNode.nodeType === 1 && !newNode._stScanned) {
newNode._stScanned = true;
_scanTree(newNode); _scanTree(newNode);
} }
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "@apigo.cc/state", "name": "@apigo.cc/state",
"version": "1.0.14", "version": "1.0.15",
"type": "module", "type": "module",
"main": "dist/state.js", "main": "dist/state.js",
"module": "dist/state.js", "module": "dist/state.js",

View File

@ -308,7 +308,7 @@ export const _scanTree = (node, scanObj = {}) => {
node._stTranslated = true; return; node._stTranslated = true; return;
} }
if (node.nodeType !== 1) return; if (node.nodeType !== 1) return;
node._stScanned = true; if (node.isConnected) node._stScanned = true;
if (!node._stTranslated) { if (!node._stTranslated) {
Array.from(node.attributes).forEach(attr => { Array.from(node.attributes).forEach(attr => {

View File

@ -29,7 +29,6 @@ if (typeof document !== 'undefined') {
mutations.forEach(mutation => { mutations.forEach(mutation => {
mutation.addedNodes.forEach(newNode => { mutation.addedNodes.forEach(newNode => {
if (newNode.isConnected && newNode.nodeType === 1 && !newNode._stScanned) { if (newNode.isConnected && newNode.nodeType === 1 && !newNode._stScanned) {
newNode._stScanned = true;
_scanTree(newNode); _scanTree(newNode);
} }
}); });