diff --git a/.changeset/flat-ants-walk.md b/.changeset/flat-ants-walk.md new file mode 100644 index 00000000..e9d70ea4 --- /dev/null +++ b/.changeset/flat-ants-walk.md @@ -0,0 +1,22 @@ +--- +'ember-scoped-css': patch +--- + +Fix an issue with strings in `class` attributes declared via sub-expressions (such as within if statements), were not properly getting scoped. + +For example: + +```js + +``` + +When the sibling CSS file only declares `a-local-class`, we would expect that + +- `global-probably` remains unchanged +- `a-local-class` gets hashed + +Note that this bug is not fixed for embroider consumers. diff --git a/ember-scoped-css/build.sh b/ember-scoped-css/build.sh index 61b05870..7e768390 100755 --- a/ember-scoped-css/build.sh +++ b/ember-scoped-css/build.sh @@ -9,5 +9,5 @@ pnpm esbuild \ src/build/app-dependency-loader.js \ src/lib/scoped-css-preprocessor.js \ src/runtime/test-support.js \ - --bundle --outdir=dist --platform=node \ + --bundle --outdir=dist --platform=node --sourcemap \ --out-extension:.js=.cjs diff --git a/ember-scoped-css/src/build/app-js-unplugin.js b/ember-scoped-css/src/build/app-js-unplugin.js index 14c04da6..f803af8e 100644 --- a/ember-scoped-css/src/build/app-js-unplugin.js +++ b/ember-scoped-css/src/build/app-js-unplugin.js @@ -48,6 +48,19 @@ export default createUnplugin(({ appDir }) => { ); }, + /** + * This whole thing is error prone, and we should switch the embroider + * technique to using a babel plugin. + * + * Using a webpack plugin is too late in the process. + * We don't want to be dealing with wire-format, because + * - it's not public API + * - it can change as ember-source is upgraded + * - the numbers are not "stable", in that they are bitwise anded and ored + * together so that storage is efficient -- which means we'd need to know + * all the opcodes and appropriately | / & to deconstruct appropriately. + * @returns + */ async transform(code, id) { const cssPath = id.replace(/(\.js)|(\.hbs)/, '.css'); const postfix = generateHash(cssPath); @@ -78,6 +91,14 @@ export default createUnplugin(({ appDir }) => { .join(' '); } + // replace strings in if conditions + // this is brittle, because subexpressions can be deeply nested + // + // this particular one is
" + // if (instruction[0] === 15 && Array.isArray(instruction[1]) && instruction[1][0] === 29) { + + // } + // add postfix to tags if ( instruction[0] === 10 && diff --git a/ember-scoped-css/src/lib/renameClass.js b/ember-scoped-css/src/lib/renameClass.js index f939ef45..85ec4cef 100644 --- a/ember-scoped-css/src/lib/renameClass.js +++ b/ember-scoped-css/src/lib/renameClass.js @@ -3,7 +3,15 @@ export default function renameClass(className, postfix, classesInCss) { const renamedClasses = classes .filter((c) => c) .map((c) => c.trim()) - .map((c) => (!classesInCss || classesInCss.has(c) ? c + '_' + postfix : c)) + .map((c) => { + if (!classesInCss || classesInCss.has(c)) { + if (c.endsWith(postfix)) return c; + + return c + '_' + postfix; + } + + return c; + }) .join(' '); const renamedWithPreservedSpaces = className.replace( diff --git a/ember-scoped-css/src/lib/rewriteHbs.js b/ember-scoped-css/src/lib/rewriteHbs.js index 619f816f..2b45ffb1 100644 --- a/ember-scoped-css/src/lib/rewriteHbs.js +++ b/ember-scoped-css/src/lib/rewriteHbs.js @@ -19,6 +19,18 @@ export default function rewriteHbs(hbs, classes, tags, postfix) { const renamedClass = renameClass(part.chars, postfix, classes); part.chars = renamedClass; + } else if (part.type === 'MustacheStatement') { + recast.traverse(part, { + StringLiteral(node) { + const renamedClass = renameClass( + node.value, + postfix, + classes, + ); + + node.value = renamedClass; + }, + }); } } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cdd27445..324905e3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -165,7 +165,7 @@ importers: version: 8.2.1 ember-auto-import: specifier: ^2.6.3 - version: 2.6.3(webpack@5.78.0) + version: 2.6.3(@glint/template@1.2.0)(webpack@5.78.0) ember-cli: specifier: ~4.12.2 version: 4.12.2 @@ -246,6 +246,10 @@ importers: version: 5.78.0 test-apps/classic-app: + dependencies: + ember-resources: + specifier: ^6.4.0 + version: 6.4.0(@glimmer/component@1.1.2)(@glimmer/tracking@1.1.2)(@glint/template@1.2.0)(ember-source@4.10.0) devDependencies: '@ember/optional-features': specifier: ^2.0.0 @@ -255,7 +259,7 @@ importers: version: 3.0.1 '@ember/test-helpers': specifier: ^3.2.0 - version: 3.2.0(ember-source@4.10.0)(webpack@5.78.0) + version: 3.2.0(@glint/template@1.2.0)(ember-source@4.10.0)(webpack@5.78.0) '@glimmer/component': specifier: ^1.1.2 version: 1.1.2(@babel/core@7.23.0) @@ -273,7 +277,7 @@ importers: version: 8.2.1 ember-auto-import: specifier: 2.6.3 - version: 2.6.3(webpack@5.78.0) + version: 2.6.3(@glint/template@1.2.0)(webpack@5.78.0) ember-cli: specifier: ~4.12.2 version: 4.12.2 @@ -312,7 +316,7 @@ importers: version: 8.0.0 ember-qunit: specifier: ^8.0.1 - version: 8.0.1(@ember/test-helpers@3.2.0)(ember-source@4.10.0)(qunit@2.20.0) + version: 8.0.1(@ember/test-helpers@3.2.0)(@glint/template@1.2.0)(ember-source@4.10.0)(qunit@2.20.0) ember-resolver: specifier: ^11.0.0 version: 11.0.0(ember-source@4.10.0) @@ -324,7 +328,7 @@ importers: version: link:../../ember-scoped-css-compat ember-source: specifier: ~4.10.0 - version: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0) + version: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) ember-style-loader: specifier: github:mainmatter/ember-style-loader#main version: github.com/mainmatter/ember-style-loader/5d262a1671a9354312a376d70df220289b8b3330 @@ -378,7 +382,7 @@ importers: version: 3.0.1 '@ember/test-helpers': specifier: ^3.2.0 - version: 3.2.0(ember-source@4.10.0)(webpack@5.78.0) + version: 3.2.0(@glint/template@1.2.0)(ember-source@4.10.0)(webpack@5.78.0) '@embroider/compat': specifier: ^3.2.1 version: 3.2.1(@embroider/core@3.2.1) @@ -411,7 +415,7 @@ importers: version: 11.0.0(webpack@5.78.0) ember-auto-import: specifier: ^2.6.3 - version: 2.6.3(webpack@5.78.0) + version: 2.6.3(@glint/template@1.2.0)(webpack@5.78.0) ember-cli: specifier: ~4.12.2 version: 4.12.2 @@ -450,7 +454,7 @@ importers: version: 8.0.0 ember-qunit: specifier: ^8.0.1 - version: 8.0.1(@ember/test-helpers@3.2.0)(ember-source@4.10.0)(qunit@2.20.0) + version: 8.0.1(@ember/test-helpers@3.2.0)(@glint/template@1.2.0)(ember-source@4.10.0)(qunit@2.20.0) ember-resolver: specifier: ^11.0.0 version: 11.0.0(ember-source@4.10.0) @@ -459,7 +463,7 @@ importers: version: link:../../ember-scoped-css ember-source: specifier: ~4.10.0 - version: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0) + version: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) ember-source-channel-url: specifier: ^3.0.0 version: 3.0.0 @@ -2221,7 +2225,7 @@ packages: - supports-color dev: true - /@ember/test-helpers@3.2.0(ember-source@4.10.0)(webpack@5.78.0): + /@ember/test-helpers@3.2.0(@glint/template@1.2.0)(ember-source@4.10.0)(webpack@5.78.0): resolution: {integrity: sha512-3yWpPsK5O77tUdCwW3HayrAcdlRitIRYMvLIG69Pkal1JMIGdNYVTvJ2R1lenhQh2syd/WFmGM07vQuDAtotQw==} engines: {node: 16.* || >= 18} peerDependencies: @@ -2232,10 +2236,10 @@ packages: '@simple-dom/interface': 1.4.0 broccoli-debug: 0.6.5 broccoli-funnel: 3.0.8 - ember-auto-import: 2.6.3(webpack@5.78.0) + ember-auto-import: 2.6.3(@glint/template@1.2.0)(webpack@5.78.0) ember-cli-babel: 7.26.11 ember-cli-htmlbars: 6.3.0 - ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0) + ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) transitivePeerDependencies: - '@glint/template' - supports-color @@ -2253,7 +2257,7 @@ packages: '@simple-dom/interface': 1.4.0 broccoli-debug: 0.6.5 broccoli-funnel: 3.0.8 - ember-auto-import: 2.6.3(webpack@5.78.0) + ember-auto-import: 2.6.3(@glint/template@1.2.0)(webpack@5.78.0) ember-cli-babel: 7.26.11 ember-cli-htmlbars: 6.3.0 ember-source: 4.12.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0) @@ -2273,7 +2277,6 @@ packages: semver: 7.5.4 transitivePeerDependencies: - supports-color - dev: true /@embroider/addon-dev@3.2.0(@glint/template@1.2.0)(rollup@3.21.8): resolution: {integrity: sha512-ISihBJQEHJQ3HBYMKh5wBP5VHiUWNRTtDs7diQCb75WTHa7lXP3UhONuJ4cX5CuWmGSwJjwKg0Z5hXxXbN0Olg==} @@ -2400,7 +2403,7 @@ packages: filesize: 10.0.12 fs-extra: 9.1.0 fs-tree-diff: 2.0.1 - handlebars: 4.7.7 + handlebars: 4.7.8 js-string-escape: 1.0.1 jsdom: 16.7.0(supports-color@8.1.1) lodash: 4.17.21 @@ -2802,7 +2805,6 @@ packages: dependencies: '@glimmer/env': 0.1.7 '@glimmer/validator': 0.44.0 - dev: true /@glimmer/util@0.44.0: resolution: {integrity: sha512-duAsm30uVK9jSysElCbLyU6QQYO2X9iLDLBIBUcCqck9qN1o3tK2qWiHbGK5d6g8E2AJ4H88UrfElkyaJlGrwg==} @@ -2816,7 +2818,6 @@ packages: /@glimmer/validator@0.44.0: resolution: {integrity: sha512-i01plR0EgFVz69GDrEuFgq1NheIjZcyTy3c7q+w7d096ddPVeVcRzU3LKaqCfovvLJ+6lJx40j45ecycASUUyw==} - dev: true /@glimmer/validator@0.84.3: resolution: {integrity: sha512-RTBV4TokUB0vI31UC7ikpV7lOYpWUlyqaKV//pRC4pexYMlmqnVhkFrdiimB/R1XyNdUOQUmnIAcdic39NkbhQ==} @@ -3347,13 +3348,7 @@ packages: /@types/fs-extra@5.1.0: resolution: {integrity: sha512-AInn5+UBFIK9FK5xc9yP5e3TQSPNNgjHByqYcj9g5elVBnDQcQL7PlO1CIRy2gWlbwK7UPYqi7vRvFA44dCmYQ==} dependencies: - '@types/node': 20.7.0 - - /@types/fs-extra@8.1.2: - resolution: {integrity: sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==} - dependencies: - '@types/node': 20.7.0 - dev: true + '@types/node': 20.7.2 /@types/fs-extra@8.1.3: resolution: {integrity: sha512-7IdV01N0u/CaVO0fuY1YmEg14HQN3+EW8mpNgg6NEfxEl/lzCa5OxlBu3iFsCAdamnYOcTQ7oEi43Xc/67Rgzw==} @@ -3372,7 +3367,7 @@ packages: resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==} dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.7.0 + '@types/node': 20.7.2 /@types/http-errors@2.0.2: resolution: {integrity: sha512-lPG6KlZs88gef6aD85z3HNkztpj7w2R7HmR3gygjfXCQmsLloWNARFkMuzKiiY8FGdh1XDpgBdrSf4aKDiA7Kg==} @@ -3394,7 +3389,7 @@ packages: /@types/keyv@3.1.4: resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} dependencies: - '@types/node': 20.7.0 + '@types/node': 20.7.2 dev: true /@types/mime@1.3.3: @@ -3423,12 +3418,8 @@ packages: resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} dev: true - /@types/node@20.7.0: - resolution: {integrity: sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==} - /@types/node@20.7.2: resolution: {integrity: sha512-RcdC3hOBOauLP+r/kRt27NrByYtDjsXyAuSbR87O6xpsvi763WI+5fbSIvYJrXnt9w4RuxhV6eAXfIs7aaf/FQ==} - dev: true /@types/node@9.6.61: resolution: {integrity: sha512-/aKAdg5c8n468cYLy2eQrcR5k6chlbNwZNGUj3TboyPa2hcO2QAJcfymlqPzMiRj8B6nYKXjzQz36minFE0RwQ==} @@ -3453,14 +3444,14 @@ packages: /@types/responselike@1.0.0: resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} dependencies: - '@types/node': 20.7.0 + '@types/node': 20.7.2 dev: true /@types/rimraf@2.0.5: resolution: {integrity: sha512-YyP+VfeaqAyFmXoTh3HChxOQMyjByRMsHU7kc5KOJkSlXudhMhQIALbYV7rHh/l8d2lX3VUQzprrcAgWdRuU8g==} dependencies: '@types/glob': 8.1.0 - '@types/node': 20.7.0 + '@types/node': 20.7.2 /@types/rsvp@4.0.5: resolution: {integrity: sha512-Vhmt0IASo026ZU20O3KP1nBZOCXduQ/Ei+vpgs0hfDZHysSIfhnMc61ZMIUuaazfYS0J9EhLz+jJsft6iYX4Kw==} @@ -4875,7 +4866,7 @@ packages: dependencies: buffer: 5.7.1 inherits: 2.0.4 - readable-stream: 3.6.1 + readable-stream: 3.6.2 /blank-object@1.0.2: resolution: {integrity: sha512-kXQ19Xhoghiyw66CUiGypnuRpWlbHAzY/+NyvqTEdTfhfQGH1/dbEMYiXju7fYKIFePpzp/y9dsu5Cu/PkmawQ==} @@ -6929,6 +6920,18 @@ packages: /electron-to-chromium@1.4.531: resolution: {integrity: sha512-H6gi5E41Rn3/mhKlPaT1aIMg/71hTAqn0gYEllSuw9igNWtvQwu185jiCZoZD29n7Zukgh7GVZ3zGf0XvkhqjQ==} + /ember-async-data@1.0.2(ember-source@4.10.0): + resolution: {integrity: sha512-HCnQnnPCV5A7FADoW6/e+48PVxQ1ElatxZeJJoTb2UuklMHK8CpdAvEILVC0qtEeyIEbcG/LyOIxuHK0ja63zQ==} + peerDependencies: + ember-source: '>=4.8.4' + dependencies: + '@ember/test-waiters': 3.0.2 + '@embroider/addon-shim': 1.8.6 + ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) + transitivePeerDependencies: + - supports-color + dev: false + /ember-auto-import@2.6.3(@glint/template@1.2.0): resolution: {integrity: sha512-uLhrRDJYWCRvQ4JQ1e64XlSrqAKSd6PXaJ9ZsZI6Tlms9T4DtQFxNXasqji2ZRJBVrxEoLCRYX3RTldsQ0vNGQ==} engines: {node: 12.* || 14.* || >= 16} @@ -6953,7 +6956,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) fs-extra: 10.1.0 fs-tree-diff: 2.0.1 - handlebars: 4.7.7 + handlebars: 4.7.8 js-string-escape: 1.0.1 lodash: 4.17.21 mini-css-extract-plugin: 2.7.6(webpack@5.78.0) @@ -6970,7 +6973,7 @@ packages: - webpack dev: true - /ember-auto-import@2.6.3(webpack@5.78.0): + /ember-auto-import@2.6.3(@glint/template@1.2.0)(webpack@5.78.0): resolution: {integrity: sha512-uLhrRDJYWCRvQ4JQ1e64XlSrqAKSd6PXaJ9ZsZI6Tlms9T4DtQFxNXasqji2ZRJBVrxEoLCRYX3RTldsQ0vNGQ==} engines: {node: 12.* || 14.* || >= 16} dependencies: @@ -6994,7 +6997,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) fs-extra: 10.1.0 fs-tree-diff: 2.0.1 - handlebars: 4.7.7 + handlebars: 4.7.8 js-string-escape: 1.0.1 lodash: 4.17.21 mini-css-extract-plugin: 2.7.6(webpack@5.78.0) @@ -7017,7 +7020,7 @@ packages: ember-source: ^3.28.0 || ^4.0.0 dependencies: ember-cli-babel: 7.26.11 - ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0) + ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) git-repo-info: 2.1.1 transitivePeerDependencies: - supports-color @@ -7583,18 +7586,18 @@ packages: - supports-color dev: true - /ember-qunit@8.0.1(@ember/test-helpers@3.2.0)(ember-source@4.10.0)(qunit@2.20.0): + /ember-qunit@8.0.1(@ember/test-helpers@3.2.0)(@glint/template@1.2.0)(ember-source@4.10.0)(qunit@2.20.0): resolution: {integrity: sha512-13PtywHNPTQKkDW4o8QRkJvcdsZr8hRyvh6xh/YLAX8+HaRLd3nPL8mBF4O/Kur/DAj3QWLvjzktZ2uRNGSh3A==} peerDependencies: '@ember/test-helpers': '>=3.0.3' ember-source: '>=4.0.0' qunit: ^2.13.0 dependencies: - '@ember/test-helpers': 3.2.0(ember-source@4.10.0)(webpack@5.78.0) + '@ember/test-helpers': 3.2.0(@glint/template@1.2.0)(ember-source@4.10.0)(webpack@5.78.0) '@embroider/addon-shim': 1.8.6 '@embroider/macros': 1.13.1(@glint/template@1.2.0) ember-cli-test-loader: 3.1.0 - ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0) + ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) qunit: 2.20.0 transitivePeerDependencies: - '@glint/template' @@ -7629,7 +7632,7 @@ packages: optional: true dependencies: ember-cli-babel: 7.26.11 - ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0) + ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) transitivePeerDependencies: - supports-color dev: true @@ -7649,6 +7652,35 @@ packages: - supports-color dev: true + /ember-resources@6.4.0(@glimmer/component@1.1.2)(@glimmer/tracking@1.1.2)(@glint/template@1.2.0)(ember-source@4.10.0): + resolution: {integrity: sha512-F5tfwhu8yRrPsMQk5nJWAZJuCi1xvGaTHp3izT+8rwuBXZSvjJAW+EapWNhKR7SYmtail9cPVwh37lcDd6HLXQ==} + peerDependencies: + '@ember/test-waiters': ^3.0.0 + '@glimmer/component': ^1.1.2 + '@glimmer/tracking': ^1.1.2 + '@glint/template': ^1.0.0-beta.3 || ^1.0.0 + ember-concurrency: ^2.0.0 || ^3.0.0 + ember-source: ^3.28.0 || ^4.0.0 || ^5.0.0 + peerDependenciesMeta: + '@ember/test-waiters': + optional: true + '@glimmer/component': + optional: true + ember-concurrency: + optional: true + dependencies: + '@babel/runtime': 7.23.1 + '@embroider/addon-shim': 1.8.6 + '@embroider/macros': 1.13.1(@glint/template@1.2.0) + '@glimmer/component': 1.1.2(@babel/core@7.23.0) + '@glimmer/tracking': 1.1.2 + '@glint/template': 1.2.0 + ember-async-data: 1.0.2(ember-source@4.10.0) + ember-source: 4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0) + transitivePeerDependencies: + - supports-color + dev: false + /ember-rfc176-data@0.3.18: resolution: {integrity: sha512-JtuLoYGSjay1W3MQAxt3eINWXNYYQliK90tLwtb8aeCuQK8zKGCRbBodVIrkcTqshULMnRuTOS6t1P7oQk3g6Q==} @@ -7672,7 +7704,7 @@ packages: - encoding dev: true - /ember-source@4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(webpack@5.78.0): + /ember-source@4.10.0(@babel/core@7.23.0)(@glimmer/component@1.1.2)(@glint/template@1.2.0)(webpack@5.78.0): resolution: {integrity: sha512-Y7+M+vSygMrpq4szsnpik3PxdVVA7ApuwU2L/l9Os+qpPqIKy4hT0Rw/17z4b87HNEX03jv7ueMbgcpxjUf1Kw==} engines: {node: '>= 14.*'} peerDependencies: @@ -7691,7 +7723,7 @@ packages: broccoli-funnel: 3.0.8 broccoli-merge-trees: 4.2.0 chalk: 4.1.2 - ember-auto-import: 2.6.3(webpack@5.78.0) + ember-auto-import: 2.6.3(@glint/template@1.2.0)(webpack@5.78.0) ember-cli-babel: 7.26.11 ember-cli-get-component-path-option: 1.0.0 ember-cli-is-package-missing: 1.0.0 @@ -7710,7 +7742,6 @@ packages: - '@glint/template' - supports-color - webpack - dev: true /ember-source@4.12.0(@babel/core@7.23.0)(@glimmer/component@1.1.2): resolution: {integrity: sha512-h0lV902A4Mny2eiqXPy15uXXoCc7BnUegE4axLAy4IoxEkJ1o5h0aLJFiB4Tzb1htx8vgHjJz//Y5Jig7NSDTw==} @@ -7771,7 +7802,7 @@ packages: broccoli-funnel: 3.0.8 broccoli-merge-trees: 4.2.0 chalk: 4.1.2 - ember-auto-import: 2.6.3(webpack@5.78.0) + ember-auto-import: 2.6.3(@glint/template@1.2.0)(webpack@5.78.0) ember-cli-babel: 7.26.11 ember-cli-get-component-path-option: 1.0.0 ember-cli-is-package-missing: 1.0.0 @@ -9718,18 +9749,6 @@ packages: resolution: {integrity: sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw==} dev: true - /handlebars@4.7.7: - resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==} - engines: {node: '>=0.4.7'} - hasBin: true - dependencies: - minimist: 1.2.8 - neo-async: 2.6.2 - source-map: 0.6.1 - wordwrap: 1.0.0 - optionalDependencies: - uglify-js: 3.17.4 - /handlebars@4.7.8: resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==} engines: {node: '>=0.4.7'} @@ -9741,7 +9760,6 @@ packages: wordwrap: 1.0.0 optionalDependencies: uglify-js: 3.17.4 - dev: true /hard-rejection@2.1.0: resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} @@ -10592,7 +10610,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 20.7.0 + '@types/node': 20.7.2 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -12649,14 +12667,6 @@ packages: isarray: 0.0.1 string_decoder: 0.10.31 - /readable-stream@3.6.1: - resolution: {integrity: sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==} - engines: {node: '>= 6'} - dependencies: - inherits: 2.0.4 - string_decoder: 1.3.0 - util-deprecate: 1.0.2 - /readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -12664,7 +12674,6 @@ packages: inherits: 2.0.4 string_decoder: 1.3.0 util-deprecate: 1.0.2 - dev: true /readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} @@ -13014,7 +13023,7 @@ packages: resolution: {integrity: sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==} engines: {node: '>=8.3'} dependencies: - '@types/fs-extra': 8.1.2 + '@types/fs-extra': 8.1.3 colorette: 1.4.0 fs-extra: 8.1.0 globby: 10.0.1 @@ -14267,7 +14276,7 @@ packages: resolution: {integrity: sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==} dependencies: inherits: 2.0.4 - readable-stream: 3.6.1 + readable-stream: 3.6.2 dev: true /through@2.3.8: diff --git a/test-apps/classic-app/app/components/subexpression.css b/test-apps/classic-app/app/components/subexpression.css new file mode 100644 index 00000000..5a0ed9e8 --- /dev/null +++ b/test-apps/classic-app/app/components/subexpression.css @@ -0,0 +1,3 @@ +.a-local-class { + color: blue; +} diff --git a/test-apps/classic-app/app/components/subexpression.gjs b/test-apps/classic-app/app/components/subexpression.gjs new file mode 100644 index 00000000..6c01fa6a --- /dev/null +++ b/test-apps/classic-app/app/components/subexpression.gjs @@ -0,0 +1,5 @@ + diff --git a/test-apps/classic-app/package.json b/test-apps/classic-app/package.json index ef9c78ec..8687e701 100644 --- a/test-apps/classic-app/package.json +++ b/test-apps/classic-app/package.json @@ -70,5 +70,8 @@ }, "ember": { "edition": "octane" + }, + "dependencies": { + "ember-resources": "^6.4.0" } } diff --git a/test-apps/classic-app/tests/integration/components/subexpression-test.gjs b/test-apps/classic-app/tests/integration/components/subexpression-test.gjs new file mode 100644 index 00000000..54520a7a --- /dev/null +++ b/test-apps/classic-app/tests/integration/components/subexpression-test.gjs @@ -0,0 +1,34 @@ +import { render, settled } from '@ember/test-helpers'; +import { module, test } from 'qunit'; + +import SubExpression from 'classic-app/components/subexpression'; +import { setupRenderingTest } from 'classic-app/tests/helpers'; +import { cell } from 'ember-resources'; + +import { scopedClass } from 'ember-scoped-css/test-support'; + +module('Integration | Component | subexpression', function (hooks) { + setupRenderingTest(hooks); + + test('it has scoped class', async function (assert) { + let cond = cell(false); + + await render( + ); + + assert.dom('div').hasClass('global-probably'); + + cond.current = true; + await settled(); + + + assert + .dom('div') + .hasClass( + scopedClass('a-local-class', 'classic-app/components/subexpression') + ); + assert.dom('div').hasStyle({ color: 'rgb(0, 0, 255)' }); + }); +});