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

options.props not considered for HTML tag if options is a function #304

Closed
markuzzi opened this issue Mar 13, 2021 · 2 comments
Closed

options.props not considered for HTML tag if options is a function #304

markuzzi opened this issue Mar 13, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@markuzzi
Copy link

Describe the bug
I use nuxt-custom-elements to generate a ce within a shadow dom (shadow: true).
To instantiate the shadow root, I have to add the hook beforeCreateVueInstance which is only recognized if tag options are given as a function. Otherwise, the JSON.stringify ignores the function.

However, if options are given as function, the HTML entry in the test index.html is not generated with default props, since the function getTagHTMLFromEntry does not evaluate the functin.

Afaik, the solution would be to change the getTagHTMLFromEntry function's first line to
const options = typeof tag.options === 'function' ? tag.options() : (tag.options || {});

In my tests, everything works fine.

@ThornWalli ThornWalli self-assigned this Mar 13, 2021
@ThornWalli ThornWalli added the bug Something isn't working label Mar 13, 2021
github-actions bot pushed a commit that referenced this issue Mar 13, 2021
## [1.6.1](v1.6.0...v1.6.1) (2021-03-13)

### Bug Fixes

* **build:** fix custom-tag props by function ([5b6cfe6](5b6cfe6)), closes [#304](#304)
@ThornWalli
Copy link
Contributor

Fix is published! Thanks :)

@ThornWalli
Copy link
Contributor

Hello @markuzzi,

There will now be a change in relation to Shadow DOM in version 1.8.0.

An entry option shadow sets all contained tags to a shadow element with styling.

I set the hook beforeCreateVueInstance and modify the webpack configuration of the entries and modify the two loaders (vue-loader and vue-style-loader) for the shadowMode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants