From b74136d16a421e88e2116be2663c312936eb464f Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 29 Jul 2019 17:26:25 +0300 Subject: [PATCH 1/2] Update name space ( add attribute ) --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 5414c29..bb05211 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,5 @@ declare namespace ReactWebComponent { - export const create: (app: JSX.Element, tagName: string, optOutFromShadowRoot?: boolean) => void; + export const create: (app: JSX.Element, tagName: string, optOutFromShadowRoot?: boolean, observedAttributes?: string[] ) => void; } export default ReactWebComponent; From 1e5d1b1ae9318b9aeb21cc962cbff7657ca663a4 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 29 Jul 2019 17:28:49 +0300 Subject: [PATCH 2/2] add static method observedAttributes --- src/dev/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dev/index.js b/src/dev/index.js index b4ba315..27c72a8 100644 --- a/src/dev/index.js +++ b/src/dev/index.js @@ -13,7 +13,7 @@ module.exports = { * @param {string} tagName - The name of the web component. Has to be minus "-" delimited. * @param {boolean} useShadowDom - If the value is set to "true" the web component will use the `shadowDom`. The default value is true. */ - create: (app, tagName, useShadowDom = true) => { + create: (app, tagName, useShadowDom = true, observedAttributes = [] ) => { let appInstance; const lifeCycleHooks = { @@ -35,11 +35,14 @@ module.exports = { const instanceMethod = lifeCycleHooks[hook]; if (instanceMethod && appInstance && appInstance[instanceMethod]) { - appInstance[instanceMethod].apply(appInstance, instanceParams); + appInstance[instanceMethod].call(appInstance, instanceParams); } } const proto = class extends HTMLElement { + static get observedAttributes() { + return observedAttributes; + }; connectedCallback() { const webComponentInstance = this; let mountPoint = webComponentInstance;