@ribajs/core
Advanced tools
Comparing version 0.16.8 to 0.16.9
{ | ||
"name": "@ribajs/core", | ||
"description": "Core module of Riba.js", | ||
"version": "0.16.8", | ||
"version": "0.16.9", | ||
"author": "Pascal Garber <pascal@jumplink.eu>", | ||
@@ -6,0 +6,0 @@ "private": false, |
import Debug from 'debug'; | ||
import { RibaComponent } from './riba-component'; | ||
import { RibaComponent, IRibaComponentContext } from './riba-component'; | ||
import { View } from '../view'; | ||
@@ -11,2 +11,4 @@ import { EventHandler } from '../riba'; | ||
public context?: IRibaComponentContext; | ||
protected debug: Debug.IDebugger; | ||
@@ -27,3 +29,3 @@ protected view?: View; | ||
constructor(element?: HTMLElement); | ||
constructor(element?: HTMLElement, context?: IRibaComponentContext); | ||
@@ -30,0 +32,0 @@ public disconnectedFallbackCallback(): void; |
@@ -16,2 +16,7 @@ /** | ||
export interface IRibaComponentContext { | ||
fallback: boolean; | ||
view: View; | ||
} | ||
export abstract class RibaComponent extends FakeHTMLElement { | ||
@@ -21,5 +26,11 @@ | ||
/** | ||
* Context of this component, used for debugging | ||
*/ | ||
public context?: IRibaComponentContext; | ||
protected debug: Debug.IDebugger; | ||
protected view?: View; | ||
protected _bound: boolean = false; | ||
protected templateLoaded: boolean = false; | ||
@@ -46,6 +57,7 @@ | ||
constructor(element?: HTMLElement) { | ||
constructor(element?: HTMLElement, context?: IRibaComponentContext) { | ||
super(element); | ||
this.context = context; | ||
this.debug = Debug('component:RibaComponent'); | ||
this.debug('constructor called', element, this); | ||
this.debug('constructor called', element, this.context, this); | ||
@@ -52,0 +64,0 @@ if (element) { |
@@ -206,4 +206,6 @@ import { IViewOptions, Riba } from './riba'; | ||
View.debug(`Fallback for Webcomponent ${nodeName}`); | ||
const component = new COMPONENT(node); | ||
// TODO call disconnectedCallback for unbind | ||
const component = new COMPONENT(node, { | ||
fallback: true, | ||
view: this, | ||
}); | ||
this.webComponents.push(component); | ||
@@ -217,7 +219,16 @@ } else { | ||
customElements.define(nodeName, COMPONENT); | ||
// TODO ?? call unbind (on unbind this view) of this component instance to unbind this view | ||
// (not disconnectedCallback / disconnectedFallbackCallback, this is automatically called from customElements) | ||
const component = customElements.get(nodeName); | ||
component.context = { | ||
fallback: true, | ||
view: this, | ||
}; | ||
} catch (error) { | ||
console.error(error); | ||
// Fallback | ||
const component = new COMPONENT(node); | ||
// TODO call disconnectedCallback for unbind | ||
const component = new COMPONENT(node, { | ||
fallback: true, | ||
view: this, | ||
}); | ||
this.webComponents.push(component); | ||
@@ -224,0 +235,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2731695
33634