render-core 1.0.28 → 1.0.30

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.
@@ -13,7 +13,7 @@ var Component = /** @class */ (function () {
13
13
  }
14
14
  //添加数据
15
15
  if (typeof config.data == "undefined") {
16
- this.data = function () { return {}; };
16
+ this.data = {};
17
17
  }
18
18
  else {
19
19
  this.data = config.data;
@@ -87,7 +87,7 @@ var Component = /** @class */ (function () {
87
87
  return this.props;
88
88
  };
89
89
  Component.prototype.getData = function () {
90
- return this.data();
90
+ return this.data;
91
91
  };
92
92
  Component.prototype.getMethods = function () {
93
93
  return this.methods;
@@ -1,2 +1,6 @@
1
1
  import { Controller } from "../../class/controller";
2
+ import { Component } from "../../class/component";
2
3
  export declare function inject(controller: Controller, tagTemplate: Element): void;
4
+ export declare function injectMethod(controller: Controller, proto: Component): void;
5
+ export declare function injectWatcher(controller: Controller, proto: Component): void;
6
+ export declare function injectComputed(controller: Controller, proto: Component): void;
@@ -12,3 +12,21 @@ export function inject(controller, tagTemplate) {
12
12
  resolver_Refs(tagTemplate.children, refs);
13
13
  getCodeSpaceForRef(controller.raw_data, refs);
14
14
  }
15
+ export function injectMethod(controller, proto) {
16
+ var methods = Object.getOwnPropertyNames(proto.getMethods());
17
+ methods.forEach(function (value) {
18
+ Reflect.set(controller.raw_data, value, proto.getMethods()[value].bind(controller.proxyForMethods));
19
+ });
20
+ }
21
+ export function injectWatcher(controller, proto) {
22
+ var methods = Object.getOwnPropertyNames(proto.getWatcher());
23
+ methods.forEach(function (value) {
24
+ Reflect.set(controller.raw_data, value, proto.getMethods()[value].bind(controller.proxyForMethods));
25
+ });
26
+ }
27
+ export function injectComputed(controller, proto) {
28
+ var methods = Object.getOwnPropertyNames(proto.getComputed());
29
+ methods.forEach(function (value) {
30
+ Reflect.set(controller.raw_data, value, proto.getMethods()[value].bind(controller.proxyForMethods));
31
+ });
32
+ }
@@ -2,7 +2,7 @@ import { Controller } from "../../class/controller";
2
2
  import { getCodeSpaceForCommit, getCodeSpaceForPublish, getCommitMethod, getPublishMethod } from "../../core/utility/injectUtility";
3
3
  import { getProxyObject } from "../../core/proxy/getProxy";
4
4
  import { findComponent } from "../../core/render/initRender";
5
- import { inject } from "../inject/inject";
5
+ import { inject, injectComputed, injectMethod, injectWatcher } from "../inject/inject";
6
6
  import { cmd } from "../cmd/cmd";
7
7
  export function init_render(proto, parent, child, link, tagTemplate) {
8
8
  //获取控制对象
@@ -15,6 +15,9 @@ export function init_render(proto, parent, child, link, tagTemplate) {
15
15
  inject(controller, tagTemplate);
16
16
  //数据渲染代理对象
17
17
  controller.proxyForMethods = getProxyObject(controller.raw_data, controller);
18
+ injectComputed(controller, proto);
19
+ injectWatcher(controller, proto);
20
+ injectMethod(controller, proto);
18
21
  //注入commit
19
22
  getCodeSpaceForCommit(controller.raw_data, getCommitMethod(link));
20
23
  //注入receiver
@@ -38,7 +41,10 @@ export function init_render(proto, parent, child, link, tagTemplate) {
38
41
  afterRender();
39
42
  //指定渲染空间
40
43
  controller.root = renderSpace;
44
+ //将本控制对象保存到父控制对象的发布数组中
41
45
  link.to.push(controller);
46
+ //将执行空间保存到父控制对象
47
+ link.link.set(child.getAttribute("name"), controller.raw_data);
42
48
  //深度渲染
43
49
  findComponent(tagTemplate.children, controller);
44
50
  }
@@ -53,6 +59,9 @@ export function post_render(proto, parent, child, link, tagTemplate) {
53
59
  inject(controller, tagTemplate);
54
60
  //保持数据代理对象
55
61
  controller.proxyForMethods = getProxyObject(controller.raw_data, controller);
62
+ injectComputed(controller, proto);
63
+ injectWatcher(controller, proto);
64
+ injectMethod(controller, proto);
56
65
  //注入commit
57
66
  getCodeSpaceForCommit(controller.raw_data, getCommitMethod(link));
58
67
  //注入receiver
@@ -90,6 +99,9 @@ export function raw_render(proto, parent, child, link, tagTemplate) {
90
99
  controller.raw_data = proto.getData();
91
100
  //数据渲染对象
92
101
  controller.proxyForMethods = getProxyObject(controller.raw_data, controller);
102
+ injectComputed(controller, proto);
103
+ injectWatcher(controller, proto);
104
+ injectMethod(controller, proto);
93
105
  //注入commit
94
106
  getCodeSpaceForCommit(controller.raw_data, getCommitMethod(link));
95
107
  //注入receiver
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.0.28",
4
- "description": "The router for render-js",
3
+ "version": "1.0.30",
4
+ "description": "The core for render-js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {