From 298cc81f41689c2168ab7d927ac1af732ad17a40 Mon Sep 17 00:00:00 2001 From: Robbie Wagner Date: Mon, 21 Apr 2025 12:41:31 -0400 Subject: [PATCH 1/6] Fix .original deprecation --- .../lib/htmlbars-plugin/index.js | 18 ++++++++++++++++-- .../lib/htmlbars-plugin/utils.js | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/packages/ember-css-modules/lib/htmlbars-plugin/index.js b/packages/ember-css-modules/lib/htmlbars-plugin/index.js index 783ca34..4b334c2 100644 --- a/packages/ember-css-modules/lib/htmlbars-plugin/index.js +++ b/packages/ember-css-modules/lib/htmlbars-plugin/index.js @@ -62,7 +62,7 @@ module.exports = class ClassTransformPlugin { } transformStatement(node) { - if (node.path.original === 'local-class') { + if (getValue(node.path) === 'local-class') { this.transformLocalClassHelperInvocation(node); } else { this.transformPossibleComponentInvocation(node); @@ -70,7 +70,7 @@ module.exports = class ClassTransformPlugin { } transformSubexpression(node) { - if (node.path.original === 'local-class') { + if (getValue(node.path) === 'local-class') { this.transformLocalClassHelperInvocation(node); } } @@ -246,3 +246,17 @@ module.exports = class ClassTransformPlugin { return parts; } }; + +function getValue(path) { + if (!path) return; + + if ('value' in path) { + return path.value; + } + + /** + * Deprecated in ember 5.9+ + * (so we use the above for newer embers) + */ + return path.original; +} diff --git a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js index f3277e3..aa3efb5 100644 --- a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js +++ b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js @@ -21,7 +21,7 @@ function updateStringValue(node, updater) { node.chars = updater(node.chars); } else if (node.type === 'StringLiteral') { node.value = updater(node.value); - node.original = updater(node.original); + getValue(node) = updater(getValue(node)); } else { throw new Error('Unknown node type ' + node.type + ' (not a string?)'); } @@ -76,6 +76,20 @@ function pushAll(target, arr) { return target; } +function getValue(path) { + if (!path) return; + + if ('value' in path) { + return path.value; + } + + /** + * Deprecated in ember 5.9+ + * (so we use the above for newer embers) + */ + return path.original; +} + module.exports = { pushAll: pushAll, getPair: getPair, From 0db8ae348d8abcb0b284800e5ae12cb0911dba1d Mon Sep 17 00:00:00 2001 From: Robbie Wagner Date: Thu, 24 Apr 2025 13:09:51 -0400 Subject: [PATCH 2/6] Add Changelog, bump version --- CHANGELOG.md | 4 ++++ packages/ember-css-modules/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc5206..1e72f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## Unreleased +## 2.1.1 (April 4, 2019) +### Fixed +- Remove usage of .original in Ember 5.9+ to fix deprecation warnings. + ## 2.1.0 (April 2, 2024) ### Added diff --git a/packages/ember-css-modules/package.json b/packages/ember-css-modules/package.json index 05ff285..f3ca3b6 100644 --- a/packages/ember-css-modules/package.json +++ b/packages/ember-css-modules/package.json @@ -1,6 +1,6 @@ { "name": "ember-css-modules", - "version": "2.1.0", + "version": "2.1.1", "description": "CSS Modules for ambitious applications", "scripts": { "build": "ember build --environment=production", From 83d62bbd5649760324dc6b642a0f23af9d93721b Mon Sep 17 00:00:00 2001 From: Robbie Wagner Date: Thu, 24 Apr 2025 13:49:48 -0400 Subject: [PATCH 3/6] Fix assignment --- .../lib/htmlbars-plugin/utils.js | 16 +++++++++++++++- yarn.lock | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js index aa3efb5..c661611 100644 --- a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js +++ b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js @@ -21,7 +21,7 @@ function updateStringValue(node, updater) { node.chars = updater(node.chars); } else if (node.type === 'StringLiteral') { node.value = updater(node.value); - getValue(node) = updater(getValue(node)); + setValue(node, updater(getValue(node))); } else { throw new Error('Unknown node type ' + node.type + ' (not a string?)'); } @@ -90,6 +90,20 @@ function getValue(path) { return path.original; } +function setValue(node, value) { + if (!node) return; + + if ('value' in node) { + node.value = value; + } else { + /** + * Deprecated in ember 5.9+ + * (so we use the above for newer embers) + */ + path.original = value; + } +} + module.exports = { pushAll: pushAll, getPair: getPair, diff --git a/yarn.lock b/yarn.lock index 5649569..3539e4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5873,7 +5873,7 @@ ember-compatibility-helpers@^1.1.2, ember-compatibility-helpers@^1.2.0, ember-co semver "^5.4.1" "ember-css-modules@link:packages/ember-css-modules": - version "2.0.1" + version "2.1.1" dependencies: broccoli-bridge "^1.0.0" broccoli-concat "^4.2.5" From 9f8ba477cb063f67e9087b355c769b84ee15d9bb Mon Sep 17 00:00:00 2001 From: Robbie Wagner Date: Thu, 24 Apr 2025 13:53:18 -0400 Subject: [PATCH 4/6] Update utils.js --- packages/ember-css-modules/lib/htmlbars-plugin/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js index c661611..fd91ccf 100644 --- a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js +++ b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js @@ -100,7 +100,7 @@ function setValue(node, value) { * Deprecated in ember 5.9+ * (so we use the above for newer embers) */ - path.original = value; + node.original = value; } } From 91f55b0091e67372a052a0fb6313b2f3bba94f0c Mon Sep 17 00:00:00 2001 From: Robbie Wagner Date: Thu, 24 Apr 2025 14:21:15 -0400 Subject: [PATCH 5/6] Update packages/ember-css-modules/lib/htmlbars-plugin/utils.js Co-authored-by: Dan Freeman --- packages/ember-css-modules/lib/htmlbars-plugin/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js index fd91ccf..1603515 100644 --- a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js +++ b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js @@ -21,7 +21,11 @@ function updateStringValue(node, updater) { node.chars = updater(node.chars); } else if (node.type === 'StringLiteral') { node.value = updater(node.value); - setValue(node, updater(getValue(node))); + // Avoid `original` deprecation in Ember 5.9+ + let originalDesc = Object.getOwnPropertyDescriptor(node, 'original'); + if (originalDesc && originalDesc.value) { + node.original = updater(node.original); + } } else { throw new Error('Unknown node type ' + node.type + ' (not a string?)'); } From f4f5fb2ee22e0523a7cb8ccb671261cac60878e0 Mon Sep 17 00:00:00 2001 From: Robbie Wagner Date: Thu, 24 Apr 2025 14:22:09 -0400 Subject: [PATCH 6/6] Remove getValue and setValue --- .../lib/htmlbars-plugin/utils.js | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js index 1603515..3df172f 100644 --- a/packages/ember-css-modules/lib/htmlbars-plugin/utils.js +++ b/packages/ember-css-modules/lib/htmlbars-plugin/utils.js @@ -80,34 +80,6 @@ function pushAll(target, arr) { return target; } -function getValue(path) { - if (!path) return; - - if ('value' in path) { - return path.value; - } - - /** - * Deprecated in ember 5.9+ - * (so we use the above for newer embers) - */ - return path.original; -} - -function setValue(node, value) { - if (!node) return; - - if ('value' in node) { - node.value = value; - } else { - /** - * Deprecated in ember 5.9+ - * (so we use the above for newer embers) - */ - node.original = value; - } -} - module.exports = { pushAll: pushAll, getPair: getPair,