Skip to content

Commit

Permalink
added support for build in elements and react
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyOGo committed Nov 5, 2018
1 parent b6a4649 commit 43457ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/js/with-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const withReact = (WebComponent, { pure = true, passive = false } = {}) => {
// hence it's tagName could only be resolved lazily
// ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry
// therefor we don't instantiate it, but rather use a statically defined tagName property
const { tagName } = WebComponent;
const displayName = `${camelize(tagName)}React`;
const { tagName, buildinTagName } = WebComponent;
const displayName = `${camelize(buildinTagName || tagName)}React`;
const Component = pure ? React.PureComponent : React.Component;

return class WebComponentWrapper extends Component {
Expand Down Expand Up @@ -150,8 +150,9 @@ const withReact = (WebComponent, { pure = true, passive = false } = {}) => {
render() {
// eslint-disable-next-line react/prop-types
const { props: { children }, handleRef } = this;
const is = buildinTagName ? tagName : null;

return createElement(tagName, { ref: handleRef }, children);
return createElement(tagName, { ref: handleRef, is }, children);
}
};
};
Expand Down
1 change: 1 addition & 0 deletions stack/tasks/create-a-m-o.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ const writeIndexJs = (path, _name) => {
class ${className} extends ${BaseConstructor} {
static tagName = 'axa-${_name}'
${isBuiltin ? `static buildinTagName = '${buildinElement}'` : ''}
// specify runtime type-checking here, if you use custom attributes
// this will also derived your needed observed attributes automatically for you
Expand Down

0 comments on commit 43457ec

Please sign in to comment.