@viewfly/platform-browser 2.0.1 → 2.1.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/bundles/index.d.ts +6 -0
- package/bundles/index.esm.js +27 -2
- package/bundles/index.js +27 -2
- package/package.json +2 -2
package/bundles/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare function createApp<T extends NativeNode>(root: ViewFlyNode, config?: Par
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* 用于创建脱离当前 DOM 树的子节点,常用于弹窗等
|
|
23
|
+
* @deprecated 即将弃用,请使用 @viewfly/core 模块的 Portal 组件实现
|
|
23
24
|
* @param childRender
|
|
24
25
|
* @param host
|
|
25
26
|
* @example
|
|
@@ -112,6 +113,11 @@ declare class OutputTranslator {
|
|
|
112
113
|
declare class DomRenderer extends NativeRenderer<HTMLElement, Text> {
|
|
113
114
|
static NAMESPACES: Record<string, string>;
|
|
114
115
|
propMap: Record<string, Record<string, string>>;
|
|
116
|
+
/**
|
|
117
|
+
* IDL 属性赋 `''` 会被转成数字 0(如 maxLength/minLength),无法表示「未设置」。
|
|
118
|
+
* 这些键在移除时应删掉对应 content attribute。
|
|
119
|
+
*/
|
|
120
|
+
private static readonly REMOVE_VIA_ATTRIBUTE;
|
|
115
121
|
createElement(name: string, namespace: ElementNamespace): HTMLElement;
|
|
116
122
|
createTextNode(textContent: string): Text;
|
|
117
123
|
appendChild(parent: HTMLElement, newChild: any): void;
|
package/bundles/index.esm.js
CHANGED
|
@@ -93,8 +93,15 @@ class DomRenderer extends NativeRenderer {
|
|
|
93
93
|
}
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
|
|
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 };
|
|
@@ -183,6 +207,7 @@ function createApp(root, config = true) {
|
|
|
183
207
|
|
|
184
208
|
/**
|
|
185
209
|
* 用于创建脱离当前 DOM 树的子节点,常用于弹窗等
|
|
210
|
+
* @deprecated 即将弃用,请使用 @viewfly/core 模块的 Portal 组件实现
|
|
186
211
|
* @param childRender
|
|
187
212
|
* @param host
|
|
188
213
|
* @example
|
package/bundles/index.js
CHANGED
|
@@ -95,8 +95,15 @@ class DomRenderer extends core.NativeRenderer {
|
|
|
95
95
|
}
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
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 };
|
|
@@ -185,6 +209,7 @@ function createApp(root, config = true) {
|
|
|
185
209
|
|
|
186
210
|
/**
|
|
187
211
|
* 用于创建脱离当前 DOM 树的子节点,常用于弹窗等
|
|
212
|
+
* @deprecated 即将弃用,请使用 @viewfly/core 模块的 Portal 组件实现
|
|
188
213
|
* @param childRender
|
|
189
214
|
* @param host
|
|
190
215
|
* @example
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/platform-browser",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"keywords": [],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@viewfly/core": "^2.
|
|
17
|
+
"@viewfly/core": "^2.1.0",
|
|
18
18
|
"csstype": "^3.1.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|