-
Notifications
You must be signed in to change notification settings - Fork 795
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
bug: private state can conflict with global HTML attributes #3134
Labels
Bug: Validated
This PR or Issue is verified to be a bug within Stencil
Comments
14 tasks
Good catch. Shouldn't the constructor have a |
Yep! Updated the code block. |
Discussed this offline with @willmartian - turns out this isn't reproducible in Firefox v94, but is on FF 95 (and other major browsers) |
Any update on this issue , we also see this same issue with some of our components. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Stencil Version
2.10.0
Current Behavior
In the custom elements build, declaring variables on a component with the same name as a global HTML attribute will cause an error upon creating the component programmatically ala someting like
document.createElement
:Uncaught DOMException: Failed to construct 'CustomElement': The result must not have attributes
For example, given the following Stencil component:
Building with the custom elements output target will generate the following:
This violates the HTML standard's requirements for a custom element constructor:
(from https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-conformance)
Expected Behavior
I would expect Stencil to either namespace private variables to prevent this type of unintended collision, or cause a build error when declaring private variables with colliding names. The
@Prop()
decorator will already cause a warning if it detects a global attribute name is being used, but private vars and@State()
do not.Steps to Reproduce
I am seeing this issue in Ionic Frameworks Vue e2e tests, from this private state declaration: /~https://github.com/ionic-team/ionic-framework/blob/next/core/src/components/picker-internal/picker-internal.tsx#L21
This is because
inputMode
is a global attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmodeCode repro steps:
git clone /~https://github.com/willmartian/stencil-ce-repro.git
stencil_lib
runnpm ci && npm run build && npm pack
ce_test_site
runnpm ci && npm run start
Code Reproduction URL
/~https://github.com/willmartian/stencil-ce-repro
Additional Information
No response
The text was updated successfully, but these errors were encountered: