Skip to content

Commit b85fad1

Browse files
authored
Avoid triggering ember.js#19392 with synthetic attr nodes (#271)
1 parent 91a3ff3 commit b85fad1

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Unreleased
22

3+
## 1.6.2 (March 23, 2021)
4+
### Fixed
5+
- Avoid triggering (ember.js#19392)[https://github.com/emberjs/ember.js/issues/19392] when we produce synthetic class `AttrNode`s.
6+
37
## 1.6.0 (November 19, 2021)
48
### Added
59
- You can now pass `patchClassicComponent: false` in your ECM config to opt out of the deprecated monkeypatching of `Ember.Component` that will be removed entirely in 2.0 (thanks @SergeAstapov!)

packages/ember-css-modules/lib/htmlbars-plugin/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,18 @@ module.exports = class ClassTransformPlugin {
152152

153153
utils.pushAll(parts, this.localToPath(localClassAttr.value));
154154
this.divide(parts, this.isGlimmer ? 'text' : 'string');
155-
node.attributes.unshift(this.builders.attr('class', this.builders.concat(parts)));
155+
156+
let newClassAttr = this.builders.attr('class', this.builders.concat(parts));
157+
node.attributes.unshift(newClassAttr);
158+
159+
// In new-enough versions of Ember (>= 3.25 or so), we need to create a
160+
// fake good-enough `loc` whose content will start with `class=` to avoid
161+
// triggering https://github.com/emberjs/ember.js/issues/19392
162+
if (typeof localClassAttr.loc.slice === 'function') {
163+
newClassAttr.loc = localClassAttr.loc.slice({
164+
skipStart: 'local-'.length,
165+
});
166+
}
156167
}
157168

158169
localToPath(node) {

packages/ember-css-modules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-css-modules",
3-
"version": "1.6.1",
3+
"version": "1.6.2",
44
"description": "CSS Modules for ambitious applications",
55
"scripts": {
66
"build": "ember build",

0 commit comments

Comments
 (0)