Comparing version 0.5.0 to 0.5.1
@@ -53,3 +53,9 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
} | ||
return React.createElement(tag, { ref: (element) => this.setRef(element) }, this.props.children); | ||
const allBools = {}; | ||
for (const key of Object.keys(this.props)) { | ||
if (key && this.props[key] === true) { | ||
allBools[key] = true; | ||
} | ||
} | ||
return React.createElement(tag, Object.assign(Object.assign({}, allBools), { ref: (element) => this.setRef(element) }), this.props.children); | ||
} | ||
@@ -98,4 +104,4 @@ /** | ||
} | ||
if (this.isEventProp(prop, this.props)) { | ||
this._element.removeEventListener(prop[2].toLowerCase() + prop.substring(3), this.props[prop]); | ||
if (this.isEventProp(prop, this.props[prop])) { | ||
this.removeEventListener(prop, this.props[prop]); | ||
} | ||
@@ -102,0 +108,0 @@ } |
{ | ||
"name": "wc-react", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Web Components wrapper class for React", | ||
@@ -5,0 +5,0 @@ "author": "metulev", |
@@ -5,3 +5,3 @@ # React wrapper for web components | ||
Use `wc-react` to simplify usage of web components in React. This is a is a light wrapper to helps manage events and props of the web component. | ||
Use `wc-react` to simplify usage of web components in React. This is a light wrapper to help manage events and props of the web component. | ||
@@ -8,0 +8,0 @@ ```tsx |
@@ -72,6 +72,16 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
} | ||
const allBools = {}; | ||
for (const key of Object.keys(this.props)) { | ||
if (key && this.props[key] === true) { | ||
allBools[key] = true; | ||
} | ||
} | ||
return React.createElement( | ||
tag, | ||
{ ref: (element: HTMLElement) => this.setRef(element) }, | ||
{ | ||
...allBools, | ||
ref: (element: HTMLElement) => this.setRef(element) | ||
}, | ||
this.props.children | ||
@@ -128,7 +138,4 @@ ); | ||
if (this.isEventProp(prop, this.props)) { | ||
this._element.removeEventListener( | ||
prop[2].toLowerCase() + prop.substring(3), | ||
this.props[prop] | ||
); | ||
if (this.isEventProp(prop, this.props[prop])) { | ||
this.removeEventListener(prop, this.props[prop]); | ||
} | ||
@@ -261,2 +268,2 @@ } | ||
return component; | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
27021
557