discourse/app/assets/javascripts/patches/ember-this-fallback+0.4.0+003+exclude-strict-mode.patch
Jarek Radosz 6d9fcf8f76
DEV: Don't apply this-fallback to strict-mode components (#25216)
fixes the issue with imported components references in plugin gjs files
2024-01-11 11:35:00 +01:00

77 lines
3.1 KiB
Diff

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}`);