-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Variables clash with element in test suite #20819
Comments
thanks for reporting! this is intended, and not a bug -- all locally defined variables are accessible within the |
Hmm, I can understand that in traditional javascript, say like: console.log(span); // ReferenceError: Cannot access 'span' before initialization
const span = ... But in this case, the DOM Element, |
it kinda does, like -- this is valid: const span = find('span');
await render(
<template>
<span>Hello World</span> error -- undefined is not a component
</template>
);
assert.dom(span).hasText(); because this is valid const span = <template>
<div>lol not a span {{yield}}</div>
</template>;
await render(
<template>
<span>Hello World</span> no error
</template>
); real-world use cases look more like this though: import { GoogleHeader } from './brands/google';
import { GitHubHeader } from './brands/github';
const BRANDING_MAP = {
'google': GoogleHeader,
'github': GitHubHeader,
}
const branding = BRANDING_MAP[window.customer.name];
await render(
<template>
<branding>
...
</branding>
</template>
); |
ok. |
ah! the working was the bug -- see here for discussion:
the reason this had to happen is because we need to be able to safely introduce new keywords to the templating language without changing behavior of existing-imported things. |
thank you for the context |
🐞 Describe the Bug
Tests fail if variables clash with elements in the template
Example
🔬 Minimal Reproduction
Minimal reproduction
😕 Actual Behavior
Test errors
🤔 Expected Behavior
I should be allowed to chose the variable name
🌍 Environment
➕ Additional Context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: