| 4 | import { Node as ShellNode } from './node'; |
| 5 | |
| 6 | export class Prop implements IPublicModelProp { |
| 7 | private readonly [propSymbol]: InnerProp; |
| 8 | |
| 9 | constructor(prop: InnerProp) { |
| 10 | this[propSymbol] = prop; |
| 11 | } |
| 12 | |
| 13 | static create(prop: InnerProp | undefined | null): IPublicModelProp | null { |
| 14 | if (!prop) { |
| 15 | return null; |
| 16 | } |
| 17 | return new Prop(prop); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * id |
| 22 | */ |
| 23 | get id(): string { |
| 24 | return this[propSymbol].id; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * key 值 |
| 29 | * get key of prop |
| 30 | */ |
| 31 | get key(): string | number | undefined { |
| 32 | return this[propSymbol].key; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * 返回当前 prop 的路径 |
| 37 | */ |
| 38 | get path(): string[] { |
| 39 | return this[propSymbol].path; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * 返回所属的节点实例 |
| 44 | */ |
| 45 | get node(): IPublicModelNode | null { |
| 46 | return ShellNode.create(this[propSymbol].getNode()); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * return the slot node (only if the current prop represents a slot) |
| 51 | */ |
| 52 | get slotNode(): IPublicModelNode | null { |
| 53 | return ShellNode.create(this[propSymbol].slotNode); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * judge if it is a prop or not |
| 58 | */ |
| 59 | get isProp(): boolean { |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…