DEV: Don't apply this-fallback to strict-mode components (#25216)

fixes the issue with imported components references in plugin gjs files
This commit is contained in:
Jarek Radosz 2024-01-11 11:35:00 +01:00 committed by GitHub
parent cc917a1d7f
commit 6d9fcf8f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 92 additions and 85 deletions

View File

@ -0,0 +1,76 @@
diff --git a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
index a8ee337..9b144de 100644
--- a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
+++ b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
@@ -60,9 +60,15 @@ class ThisFallbackPlugin {
handleBlock() {
return {
enter: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.scopeStack.push(node.blockParams);
},
exit: () => {
+ if (this.env.strictMode) {
+ return;
+ }
this.scopeStack.pop();
},
};
@@ -70,6 +76,9 @@ class ThisFallbackPlugin {
handleAttrNodes() {
return {
enter: (elementNode, elementPath) => {
+ if (this.env.strictMode) {
+ return;
+ }
const ambiguousHeads = new Map();
const blockParamName = (0, scope_stack_1.unusedNameLike)('maybeHelpers', this.scopeStack);
for (const attrNode of elementNode.attributes) {
@@ -119,6 +128,9 @@ class ThisFallbackPlugin {
return {
keys: {
params: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
const { scopeStack } = this;
node.params = node.params.map((expr) => {
if ((0, fallback_1.needsFallback)(expr, scopeStack)) {
@@ -131,6 +143,9 @@ class ThisFallbackPlugin {
});
},
hash: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
const { scopeStack } = this;
node.hash.pairs = node.hash.pairs.map((pair) => {
const { key, value: expr, loc } = pair;
@@ -149,6 +164,9 @@ class ThisFallbackPlugin {
handleMustache() {
return {
enter: (node, path) => {
+ if (this.env.strictMode) {
+ return;
+ }
// Alias node to n so that the type of `node` doesn't get narrowed,
// which prevents mutation
const n = node;
@@ -174,9 +192,15 @@ class ThisFallbackPlugin {
handleTemplate() {
return {
enter: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.logger.debug("before: '%s'", (0, string_1.squish)((0, syntax_1.print)(node)));
},
exit: (node, path) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.logger.debug("after_: '%s'", (0, string_1.squish)((0, syntax_1.print)(node)));
if (this.scopeStack.size !== 1) {
throw new Error(`unbalanced ScopeStack push and pop, ScopeStack size is ${this.scopeStack.size}`);

View File

@ -37,10 +37,6 @@ export default class List extends Component {
return this.args.itemComponent ?? Item; return this.args.itemComponent ?? Item;
} }
get emptyStateComponent() {
return EmptyState;
}
@action @action
loadCollection() { loadCollection() {
discourseDebounce(this, this.debouncedLoadCollection, INPUT_DELAY); discourseDebounce(this, this.debouncedLoadCollection, INPUT_DELAY);
@ -57,7 +53,7 @@ export default class List extends Component {
{{yield (hash Item=(component this.itemComponent item=item))}} {{yield (hash Item=(component this.itemComponent item=item))}}
{{else}} {{else}}
{{#if @collection.fetchedOnce}} {{#if @collection.fetchedOnce}}
{{yield (hash EmptyState=this.emptyStateComponent)}} {{yield (hash EmptyState=EmptyState)}}
{{/if}} {{/if}}
{{/each}} {{/each}}
</div> </div>

View File

@ -12,60 +12,20 @@ import ThreadsListButton from "./threads-list-button";
import ToggleDrawerButton from "./toggle-drawer-button"; import ToggleDrawerButton from "./toggle-drawer-button";
export default class ChatNavbarActions extends Component { export default class ChatNavbarActions extends Component {
get openDrawerButtonComponent() {
return OpenDrawerButton;
}
get newChannelButtonComponent() {
return NewChannelButton;
}
get threadTrackingDropdownComponent() {
return ThreadTrackingDropdown;
}
get closeThreadButtonComponent() {
return CloseThreadButton;
}
get closeThreadsButtonComponent() {
return CloseThreadsButton;
}
get threadSettingsButtonComponent() {
return ThreadSettingsButton;
}
get threadsListButtonComponent() {
return ThreadsListButton;
}
get closeDrawerButtonComponent() {
return CloseDrawerButton;
}
get toggleDrawerButtonComponent() {
return ToggleDrawerButton;
}
get chatNavbarFullPageButtonComponent() {
return FullPageButton;
}
<template> <template>
<nav class="c-navbar__actions"> <nav class="c-navbar__actions">
{{yield {{yield
(hash (hash
OpenDrawerButton=this.openDrawerButtonComponent OpenDrawerButton=OpenDrawerButton
NewChannelButton=this.newChannelButtonComponent NewChannelButton=NewChannelButton
ThreadTrackingDropdown=this.threadTrackingDropdownComponent ThreadTrackingDropdown=ThreadTrackingDropdown
CloseThreadButton=this.closeThreadButtonComponent CloseThreadButton=CloseThreadButton
CloseThreadsButton=this.closeThreadsButtonComponent CloseThreadsButton=CloseThreadsButton
ThreadSettingsButton=this.threadSettingsButtonComponent ThreadSettingsButton=ThreadSettingsButton
ThreadsListButton=this.threadsListButtonComponent ThreadsListButton=ThreadsListButton
CloseDrawerButton=this.closeDrawerButtonComponent CloseDrawerButton=CloseDrawerButton
ToggleDrawerButton=this.toggleDrawerButtonComponent ToggleDrawerButton=ToggleDrawerButton
FullPageButton=this.chatNavbarFullPageButtonComponent FullPageButton=FullPageButton
) )
}} }}
</nav> </nav>

View File

@ -9,22 +9,6 @@ import ChannelTitle from "./channel-title";
import Title from "./title"; import Title from "./title";
export default class ChatNavbar extends Component { export default class ChatNavbar extends Component {
get buttonComponent() {
return BackButton;
}
get titleComponent() {
return Title;
}
get actionsComponent() {
return Actions;
}
get channelTitleComponent() {
return ChannelTitle;
}
<template> <template>
{{! template-lint-disable no-invalid-interactive }} {{! template-lint-disable no-invalid-interactive }}
<div <div
@ -34,10 +18,10 @@ export default class ChatNavbar extends Component {
<nav class="c-navbar"> <nav class="c-navbar">
{{yield {{yield
(hash (hash
BackButton=this.buttonComponent BackButton=BackButton
ChannelTitle=this.channelTitleComponent ChannelTitle=ChannelTitle
Title=this.titleComponent Title=Title
Actions=this.actionsComponent Actions=Actions
) )
}} }}
</nav> </nav>

View File

@ -1,11 +1,6 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import SubTitle from "./sub-title";
export default class ChatNavbarSubTitle extends Component { export default class ChatNavbarSubTitle extends Component {
get subTitleComponent() {
return SubTitle;
}
<template> <template>
<div class="c-navbar__sub-title"> <div class="c-navbar__sub-title">
{{#if (has-block)}} {{#if (has-block)}}

View File

@ -4,10 +4,6 @@ import icon from "discourse-common/helpers/d-icon";
import SubTitle from "./sub-title"; import SubTitle from "./sub-title";
export default class ChatNavbarTitle extends Component { export default class ChatNavbarTitle extends Component {
get subTitleComponent() {
return SubTitle;
}
<template> <template>
<div title={{@title}} class="c-navbar__title"> <div title={{@title}} class="c-navbar__title">
{{#if (has-block)}} {{#if (has-block)}}
@ -15,7 +11,7 @@ export default class ChatNavbarTitle extends Component {
{{icon @icon}} {{icon @icon}}
{{/if}} {{/if}}
{{@title}} {{@title}}
{{yield (hash SubTitle=this.subTitleComponent)}} {{yield (hash SubTitle=SubTitle)}}
{{else}} {{else}}
{{#if @icon}} {{#if @icon}}
{{icon @icon}} {{icon @icon}}