@viewfly/platform-browser 2.0.1 → 2.0.2

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.
@@ -112,6 +112,11 @@ declare class OutputTranslator {
112
112
  declare class DomRenderer extends NativeRenderer<HTMLElement, Text> {
113
113
  static NAMESPACES: Record<string, string>;
114
114
  propMap: Record<string, Record<string, string>>;
115
+ /**
116
+ * IDL 属性赋 `''` 会被转成数字 0(如 maxLength/minLength),无法表示「未设置」。
117
+ * 这些键在移除时应删掉对应 content attribute。
118
+ */
119
+ private static readonly REMOVE_VIA_ATTRIBUTE;
115
120
  createElement(name: string, namespace: ElementNamespace): HTMLElement;
116
121
  createTextNode(textContent: string): Text;
117
122
  appendChild(parent: HTMLElement, newChild: any): void;
@@ -93,8 +93,15 @@ class DomRenderer extends NativeRenderer {
93
93
  }
94
94
  return;
95
95
  }
96
- if (key in node) {
97
- node[key] = '';
96
+ const map = this.propMap[node.tagName];
97
+ const resolvedKey = map ? (map[key] || key) : key;
98
+ const attrName = DomRenderer.REMOVE_VIA_ATTRIBUTE[resolvedKey];
99
+ if (attrName) {
100
+ node.removeAttribute(attrName);
101
+ return;
102
+ }
103
+ if (resolvedKey in node) {
104
+ node[resolvedKey] = '';
98
105
  }
99
106
  else {
100
107
  node.removeAttribute(key);
@@ -169,6 +176,23 @@ Object.defineProperty(DomRenderer, "NAMESPACES", {
169
176
  mathml: 'http://www.w3.org/1998/Math/MathML',
170
177
  }
171
178
  });
179
+ /**
180
+ * IDL 属性赋 `''` 会被转成数字 0(如 maxLength/minLength),无法表示「未设置」。
181
+ * 这些键在移除时应删掉对应 content attribute。
182
+ */
183
+ Object.defineProperty(DomRenderer, "REMOVE_VIA_ATTRIBUTE", {
184
+ enumerable: true,
185
+ configurable: true,
186
+ writable: true,
187
+ value: {
188
+ maxLength: 'maxlength',
189
+ minLength: 'minlength',
190
+ size: 'size',
191
+ cols: 'cols',
192
+ rows: 'rows',
193
+ tabIndex: 'tabindex',
194
+ }
195
+ });
172
196
 
173
197
  function createApp(root, config = true) {
174
198
  const c = { autoUpdate: true };
package/bundles/index.js CHANGED
@@ -95,8 +95,15 @@ class DomRenderer extends core.NativeRenderer {
95
95
  }
96
96
  return;
97
97
  }
98
- if (key in node) {
99
- node[key] = '';
98
+ const map = this.propMap[node.tagName];
99
+ const resolvedKey = map ? (map[key] || key) : key;
100
+ const attrName = DomRenderer.REMOVE_VIA_ATTRIBUTE[resolvedKey];
101
+ if (attrName) {
102
+ node.removeAttribute(attrName);
103
+ return;
104
+ }
105
+ if (resolvedKey in node) {
106
+ node[resolvedKey] = '';
100
107
  }
101
108
  else {
102
109
  node.removeAttribute(key);
@@ -171,6 +178,23 @@ Object.defineProperty(DomRenderer, "NAMESPACES", {
171
178
  mathml: 'http://www.w3.org/1998/Math/MathML',
172
179
  }
173
180
  });
181
+ /**
182
+ * IDL 属性赋 `''` 会被转成数字 0(如 maxLength/minLength),无法表示「未设置」。
183
+ * 这些键在移除时应删掉对应 content attribute。
184
+ */
185
+ Object.defineProperty(DomRenderer, "REMOVE_VIA_ATTRIBUTE", {
186
+ enumerable: true,
187
+ configurable: true,
188
+ writable: true,
189
+ value: {
190
+ maxLength: 'maxlength',
191
+ minLength: 'minlength',
192
+ size: 'size',
193
+ cols: 'cols',
194
+ rows: 'rows',
195
+ tabIndex: 'tabindex',
196
+ }
197
+ });
174
198
 
175
199
  function createApp(root, config = true) {
176
200
  const c = { autoUpdate: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/platform-browser",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "This project is used to enable the Viewfly framework to run in a browser.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",