render-core 1.3.33 → 1.3.35
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/core/cmd/method/v-on.d.ts +2 -1
- package/core/cmd/method/v-on.js +9 -3
- package/core/cmd/react/v-model.js +2 -2
- package/core/inject/inject.js +1 -1
- package/core/utility/cmdUtility.js +1 -1
- package/core/utility/inputUtility.js +1 -3
- package/core/utility/modelUtility.d.ts +1 -1
- package/core/utility/modelUtility.js +7 -2
- package/package.json +1 -1
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
* @param elements
|
|
4
4
|
* @param methods
|
|
5
5
|
* @param data
|
|
6
|
+
* @param rawData
|
|
6
7
|
*/
|
|
7
|
-
export declare function resolver_event(elements: HTMLCollection, methods: {}, data: {}): void;
|
|
8
|
+
export declare function resolver_event(elements: HTMLCollection, methods: {}, data: {}, rawData: {}): void;
|
package/core/cmd/method/v-on.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* @param elements
|
|
4
4
|
* @param methods
|
|
5
5
|
* @param data
|
|
6
|
+
* @param rawData
|
|
6
7
|
*/
|
|
7
|
-
export function resolver_event(elements, methods, data) {
|
|
8
|
+
export function resolver_event(elements, methods, data, rawData) {
|
|
8
9
|
//遍历所有的元素节点
|
|
9
10
|
for (var i = 0; i < elements.length; i++) {
|
|
10
11
|
//获取元素节点所有属性
|
|
@@ -20,7 +21,12 @@ export function resolver_event(elements, methods, data) {
|
|
|
20
21
|
var method = elements[i].getAttribute(result[k]);
|
|
21
22
|
elements[i].removeAttribute(result[k]);
|
|
22
23
|
try {
|
|
23
|
-
|
|
24
|
+
if (action.match(/^\$\$[a-zA-Z0-9_]*/) !== null) {
|
|
25
|
+
elements[i].addEventListener(action, methods[method].bind(rawData));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
elements[i].addEventListener(action, methods[method].bind(data));
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
catch (error) {
|
|
26
32
|
console.error("Can not find method:" + method + " in the component");
|
|
@@ -29,6 +35,6 @@ export function resolver_event(elements, methods, data) {
|
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
//深度解析属性
|
|
32
|
-
resolver_event(elements[i].children, methods, data);
|
|
38
|
+
resolver_event(elements[i].children, methods, data, rawData);
|
|
33
39
|
}
|
|
34
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compositionend, compositionstart,
|
|
1
|
+
import { compositionend, compositionstart, listener } from "../../utility/modelUtility";
|
|
2
2
|
/**
|
|
3
3
|
* 绑定数据模型
|
|
4
4
|
* @param nodes
|
|
@@ -13,7 +13,7 @@ export function resolver_model(nodes, data) {
|
|
|
13
13
|
nodes[i].setAttribute("name", dataName);
|
|
14
14
|
if (tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA") {
|
|
15
15
|
nodes[i].addEventListener("compositionstart", compositionstart);
|
|
16
|
-
nodes[i].addEventListener("input",
|
|
16
|
+
nodes[i].addEventListener("input", listener.bind(data));
|
|
17
17
|
nodes[i].addEventListener("compositionend", compositionend.bind(data));
|
|
18
18
|
}
|
|
19
19
|
}
|
package/core/inject/inject.js
CHANGED
|
@@ -31,7 +31,7 @@ export function injectRefs(controller) {
|
|
|
31
31
|
export function injectMethod(controller, proto) {
|
|
32
32
|
var methods = Object.getOwnPropertyNames(proto.getMethods());
|
|
33
33
|
methods.forEach(function (value) {
|
|
34
|
-
if (value.match(
|
|
34
|
+
if (value.match(/^\$\$[a-zA-Z0-9_]*/) !== null) {
|
|
35
35
|
Reflect.set(controller.raw_data, value, proto.getMethods()[value].bind(controller.raw_data));
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
@@ -21,7 +21,7 @@ export function cmdUtility(tagTemplate, proto, controller) {
|
|
|
21
21
|
//给所有元素添加上npm=tag标志
|
|
22
22
|
addLabel(tagTemplate.children, proto.getName());
|
|
23
23
|
//将元素事件绑定到元素上
|
|
24
|
-
resolver_event(tagTemplate.children, proto.getMethods(), controller.proxyForMethods);
|
|
24
|
+
resolver_event(tagTemplate.children, proto.getMethods(), controller.proxyForMethods, controller.raw_data);
|
|
25
25
|
//渲染html
|
|
26
26
|
resolver_html(tagTemplate.children, controller.proxyForMethods, controller);
|
|
27
27
|
//渲染text
|
|
@@ -79,9 +79,7 @@ function editType(element, space) {
|
|
|
79
79
|
export function filesType(element, space) {
|
|
80
80
|
Reflect.set(space, "origin", {
|
|
81
81
|
tag: element.tagName,
|
|
82
|
-
id: element.getAttribute("id")
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
files: element.files
|
|
82
|
+
id: element.getAttribute("id")
|
|
85
83
|
});
|
|
86
84
|
}
|
|
87
85
|
export function selectUtility(element, space) {
|
|
@@ -10,7 +10,7 @@ export function compositionstart(evt) {
|
|
|
10
10
|
*
|
|
11
11
|
* @param evt
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
13
|
+
export function listener(evt) {
|
|
14
14
|
if (!evt.target.hasAttribute("flag")) {
|
|
15
15
|
//Get the event element
|
|
16
16
|
var element = evt.target;
|
|
@@ -29,7 +29,12 @@ export function listerner(evt) {
|
|
|
29
29
|
break;
|
|
30
30
|
}
|
|
31
31
|
//Update the value
|
|
32
|
-
|
|
32
|
+
if (element.type === "file") {
|
|
33
|
+
this[element.name] = element.files;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this[element.name] = element.value;
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
/**
|