render-core 1.0.74 → 1.0.77
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/v-el.d.ts +1 -1
- package/core/cmd/v-el.js +19 -1
- package/core/cmd/v-html.js +6 -1
- package/core/cmd/v-txt.js +7 -3
- package/core/inject/inject.js +2 -2
- package/core/proxy/getProxy.js +7 -0
- package/library/cmd/cmd.js +3 -0
- package/package.json +1 -1
package/core/cmd/v-el.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function express_langulage(): void;
|
|
1
|
+
export declare function express_langulage(elements: HTMLCollection, data: {}): void;
|
package/core/cmd/v-el.js
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
export function express_langulage() {
|
|
1
|
+
export function express_langulage(elements, data) {
|
|
2
|
+
for (var i = 0; i < elements.length; i++) {
|
|
3
|
+
if (elements[i].hasChildNodes()) {
|
|
4
|
+
if (!(elements[i].children.length > 0)) {
|
|
5
|
+
for (var j = 0; j < elements[i].childNodes.length; j++) {
|
|
6
|
+
if (elements[i].childNodes[j].nodeType === 3) {
|
|
7
|
+
var result = elements[i].childNodes[j].nodeValue.match(/^\{\{([a-zA-Z]+)}}$/g);
|
|
8
|
+
var property = result[0].replace("{", "").replace("}", "");
|
|
9
|
+
try {
|
|
10
|
+
elements[i].childNodes[j].nodeValue = data[property]();
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
elements[i].childNodes[j].nodeValue = data[property];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
2
20
|
}
|
package/core/cmd/v-html.js
CHANGED
|
@@ -5,7 +5,12 @@ export function resolver_html(elements, data) {
|
|
|
5
5
|
var dataName = elements[i].getAttribute("v-html");
|
|
6
6
|
elements[i].removeAttribute("v-html");
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
|
|
8
|
+
try {
|
|
9
|
+
elements[i].innerHTML = data[dataName]();
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
elements[i].innerHTML = data[dataName];
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
var subElements = elements[i].children;
|
|
11
16
|
resolver_html(subElements, data);
|
package/core/cmd/v-txt.js
CHANGED
|
@@ -5,9 +5,13 @@ export function resolver_txt(elements, data) {
|
|
|
5
5
|
var dataName = elements[i].getAttribute("v-txt");
|
|
6
6
|
elements[i].removeAttribute("v-txt");
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
|
|
8
|
+
try {
|
|
9
|
+
elements[i].innerHTML = data[dataName]();
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
elements[i].innerHTML = data[dataName];
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
resolver_txt(subElements, data);
|
|
15
|
+
resolver_txt(elements[i].children, data);
|
|
12
16
|
}
|
|
13
17
|
}
|
package/core/inject/inject.js
CHANGED
|
@@ -22,12 +22,12 @@ export function injectMethod(controller, proto) {
|
|
|
22
22
|
export function injectWatcher(controller, proto) {
|
|
23
23
|
var methods = Object.getOwnPropertyNames(proto.getWatcher());
|
|
24
24
|
methods.forEach(function (value) {
|
|
25
|
-
Reflect.set(controller.raw_data, value, proto.
|
|
25
|
+
Reflect.set(controller.raw_data, value, proto.getWatcher()[value].bind(controller.raw_data));
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
export function injectComputed(controller, proto) {
|
|
29
29
|
var methods = Object.getOwnPropertyNames(proto.getComputed());
|
|
30
30
|
methods.forEach(function (value) {
|
|
31
|
-
Reflect.set(controller.raw_data, value, proto.
|
|
31
|
+
Reflect.set(controller.raw_data, value, proto.getComputed()[value].bind(controller.proxyForMethods));
|
|
32
32
|
});
|
|
33
33
|
}
|
package/core/proxy/getProxy.js
CHANGED
|
@@ -21,6 +21,13 @@ export function getSetter(data, updater) {
|
|
|
21
21
|
var setter = function (obj, prop, value) {
|
|
22
22
|
//更新值
|
|
23
23
|
obj[prop] = value;
|
|
24
|
+
//检查是否有watcher
|
|
25
|
+
try {
|
|
26
|
+
obj[prop]();
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.log(e.message);
|
|
30
|
+
}
|
|
24
31
|
//更新前操作
|
|
25
32
|
this.proto.getBeforeUpdate();
|
|
26
33
|
//执行更新
|
package/library/cmd/cmd.js
CHANGED
|
@@ -10,6 +10,7 @@ import { resolver_if } from "../../core/cmd/v-if";
|
|
|
10
10
|
import { resolver_switch } from "../../core/cmd/v-switch";
|
|
11
11
|
import { resolver_for_each, resolver_for_of } from "../../core/cmd/v-for";
|
|
12
12
|
import { extract_solt } from "../../core/cmd/v-solt";
|
|
13
|
+
import { express_langulage } from "../../core/cmd/v-el";
|
|
13
14
|
export function cmd(tagTemplate, proto, controller) {
|
|
14
15
|
//给所有元素添加上npm=tag标志
|
|
15
16
|
addLabel(tagTemplate.children, proto.getName());
|
|
@@ -25,6 +26,8 @@ export function cmd(tagTemplate, proto, controller) {
|
|
|
25
26
|
resolver_bind(tagTemplate.children, controller.proxyForMethods);
|
|
26
27
|
//solt
|
|
27
28
|
extract_solt(tagTemplate.children, controller);
|
|
29
|
+
//v-el
|
|
30
|
+
express_langulage(tagTemplate.children, controller.proxyForMethods);
|
|
28
31
|
}
|
|
29
32
|
export function afterCmd(templateSpace, proto, controller) {
|
|
30
33
|
//v-show
|