@leafer/data 1.0.0-rc.5 → 1.0.0-rc.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/data",
3
- "version": "1.0.0-rc.5",
3
+ "version": "1.0.0-rc.7",
4
4
  "description": "@leafer/data",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,6 +22,6 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-rc.5"
25
+ "@leafer/interface": "1.0.0-rc.7"
26
26
  }
27
27
  }
package/src/LeafData.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeafData, ILeaf, IObject, __Value } from '@leafer/interface'
1
+ import { ILeafData, ILeaf, IObject, IValue } from '@leafer/interface'
2
2
 
3
3
 
4
4
  export class LeafData implements ILeafData {
@@ -24,6 +24,18 @@ export class LeafData implements ILeafData {
24
24
  return (this as IObject)[name]
25
25
  }
26
26
 
27
+ public __getData(): IObject {
28
+ const data: IObject = { tag: this.__leaf.tag }, { __input } = this
29
+ let inputValue: IValue
30
+ for (let key in this) {
31
+ if (key[0] !== '_') {
32
+ inputValue = __input ? __input[key] : undefined
33
+ data[key] = (inputValue === undefined) ? this[key] : inputValue
34
+ }
35
+ }
36
+ return data
37
+ }
38
+
27
39
  public __setInput(name: string, value: any): void {
28
40
  this.__input || (this.__input = {})
29
41
  this.__input[name] = value
@@ -43,13 +55,14 @@ export class LeafData implements ILeafData {
43
55
 
44
56
  public __getInputData(): IObject {
45
57
  const data: IObject = { tag: this.__leaf.tag }, { __input } = this
46
- let realKey: string, value: __Value
47
-
58
+ let value: IValue, inputValue: IValue
48
59
  for (let key in this) {
49
- realKey = key.substring(1)
50
- if ((this as any)[realKey] !== undefined) {
51
- value = __input ? __input[realKey] : undefined
52
- data[realKey] = value === undefined ? this[key] : value
60
+ if (key[0] !== '_') {
61
+ value = (this as IObject)['_' + key]
62
+ if (value !== undefined) {
63
+ inputValue = __input ? __input[key] : undefined
64
+ data[key] = (inputValue === undefined) ? value : inputValue
65
+ }
53
66
  }
54
67
  }
55
68
  return data
package/types/index.d.ts CHANGED
@@ -16,6 +16,7 @@ declare class LeafData implements ILeafData {
16
16
  __naturalHeight?: number;
17
17
  constructor(leaf: ILeaf);
18
18
  __get(name: string): any;
19
+ __getData(): IObject;
19
20
  __setInput(name: string, value: any): void;
20
21
  __getInput(name: string): any;
21
22
  __removeInput(name: string): void;