Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add observed Attributes #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 5 additions & 2 deletions src/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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;
Expand Down