| @@ -29,7 +29,7 | |||||
| 29 | "eslint": "6.8.0", | 
             | 
        29 | "eslint": "6.8.0", | |
| 30 | "requirejs": "2.3.6", | 
             | 
        30 | "requirejs": "2.3.6", | |
| 31 | "tslint": "^6.1.3", | 
             | 
        31 | "tslint": "^6.1.3", | |
| 32 | 
            
                    "typescript": "4. | 
        
             | 
        32 | "typescript": "4.2.4", | |
| 33 | "yaml": "~1.7.2" | 
             | 
        33 | "yaml": "~1.7.2" | |
| 34 | } | 
             | 
        34 | } | |
| 35 | } | 
             | 
        35 | } | |
| @@ -2,25 +2,28 import { argumentNotNull } from "@implab | |||||
| 2 | import { RenditionBase } from "./RenditionBase"; | 
             | 
        2 | import { RenditionBase } from "./RenditionBase"; | |
| 3 | 
             | 
        3 | |||
| 4 | export class FunctionRendition extends RenditionBase<Node> { | 
             | 
        4 | export class FunctionRendition extends RenditionBase<Node> { | |
| 5 | 
            
                private _component: ( | 
        
             | 
        5 | private _component: (...args: any[]) => any; | |
| 6 | 
             | 
        6 | |||
| 7 | private _node: Node | undefined; | 
             | 
        7 | private _node: Node | undefined; | |
| 8 | 
             | 
        8 | |||
| 9 | 
            
                constructor(component: ( | 
        
             | 
        9 | constructor(component: (...args: any[]) => any) { | |
| 10 | super(); | 
             | 
        10 | super(); | |
| 11 | argumentNotNull(component, "component"); | 
             | 
        11 | argumentNotNull(component, "component"); | |
| 12 | 
             | 
        12 | |||
| 13 | this._component = component; | 
             | 
        13 | this._component = component; | |
| 14 | } | 
             | 
        14 | } | |
| 15 | 
             | 
        15 | |||
| 16 | _create(attrs: object, children: any[]) { | 
             | 
        16 | protected _create(attrs: object, children: any[]) { | |
| 17 | const _attrs: any = attrs || {}; | 
             | 
        17 | const _attrs: any = attrs || {}; | |
| 18 | 
            
                     | 
        
             | 
        18 | const _children = children.map(x => this.getItemDom(x)); | |
| 19 | 
             | 
        19 | this._node = this.getItemDom( | ||
| 20 | this._node = this.getItemDom(this._component.call(null, _attrs)); | 
             | 
        20 | this._component.length === 2 ? | |
| 
             | 
        21 | this._component.call(null, { ..._attrs }, _children) : | |||
| 
             | 
        22 | this._component.call(null, { ..._attrs, children: _children }) | |||
| 
             | 
        23 | ); | |||
| 21 | } | 
             | 
        24 | } | |
| 22 | 
             | 
        25 | |||
| 23 | _getDomNode() { | 
             | 
        26 | protected _getDomNode() { | |
| 24 | if (!this._node) | 
             | 
        27 | if (!this._node) | |
| 25 | throw new Error("The instance of the widget isn't created"); | 
             | 
        28 | throw new Error("The instance of the widget isn't created"); | |
| 26 | return this._node; | 
             | 
        29 | return this._node; | |
        
        General Comments 0
    
    
  
  
                      You need to be logged in to leave comments.
                      Login now
                    
                