Skip to content

Commit 381544c

Browse files
committed
Avoid triggering ember.js#19392 with synthetic attr nodes
1 parent 084cd33 commit 381544c

File tree

1 file changed

+12
-3
lines changed
  • packages/ember-css-modules/lib/htmlbars-plugin

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,18 @@ module.exports = class ClassTransformPlugin {
142142

143143
utils.pushAll(parts, this.localToPath(localClassAttr.value));
144144
this.divide(parts, 'text');
145-
node.attributes.unshift(
146-
this.builders.attr('class', this.builders.concat(parts))
147-
);
145+
146+
let newClassAttr = this.builders.attr('class', this.builders.concat(parts));
147+
node.attributes.unshift(newClassAttr);
148+
149+
// In new-enough versions of Ember (>= 3.25 or so), we need to create a
150+
// fake good-enough `loc` whose content will start with `class=` to avoid
151+
// triggering https://github.com/emberjs/ember.js/issues/19392
152+
if (typeof localClassAttr.loc.slice === 'function') {
153+
newClassAttr.loc = localClassAttr.loc.slice({
154+
skipStart: 'local-'.length,
155+
});
156+
}
148157
}
149158

150159
localToPath(node) {

0 commit comments

Comments
 (0)