Skip to content

Commit

Permalink
Fix #264 - lots of deprecations logged in newer embers
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Oct 24, 2024
1 parent 9926665 commit 329cbde
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions ember-scoped-css/src/lib/rewriteHbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export function templatePlugin({ classes, tags, postfix }) {
let cssClass;

if (
isScopedClass(node.path?.original) &&
isScopedClass(getValue(node.path)) &&
node.params?.length === 1 &&
node.params[0].type === 'StringLiteral'
) {
cssClass = node.params[0].value;
}

if (
isScopedClass(node.path?.path?.original) &&
isScopedClass(getValue(node.path)) &&
node.path?.params?.length === 1 &&
node.path?.params[0].type === 'StringLiteral'
) {
Expand All @@ -103,7 +103,7 @@ export function templatePlugin({ classes, tags, postfix }) {

SubExpression(node) {
if (
isScopedClass(node.path?.original) &&
isScopedClass(getValue(node.path)) &&
node.params?.length === 1 &&
node.params[0].type === 'StringLiteral'
) {
Expand All @@ -119,6 +119,20 @@ export function templatePlugin({ classes, tags, postfix }) {
};
}

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

export default function rewriteHbs(hbs, classes, tags, postfix) {
let ast = recast.parse(hbs);

Expand Down

0 comments on commit 329cbde

Please sign in to comment.