Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid triggering ember.js#19392 with synthetic attr nodes #270

Merged
merged 2 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## Unreleased

## 2.0.1 (March 23, 2022)

### Fixed
- Avoid triggering (ember.js#19392)[https://github.com/emberjs/ember.js/issues/19392] when we produce synthetic class `AttrNode`s.

## 2.0.0 (November 22, 2021)

This major release of Ember CSS Modules primarily removes support for deprecated patterns and updates our minimum support for other elements of the ecosystem.
Expand Down
15 changes: 12 additions & 3 deletions packages/ember-css-modules/lib/htmlbars-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,18 @@ module.exports = class ClassTransformPlugin {

utils.pushAll(parts, this.localToPath(localClassAttr.value));
this.divide(parts, 'text');
node.attributes.unshift(
this.builders.attr('class', this.builders.concat(parts))
);

let newClassAttr = this.builders.attr('class', this.builders.concat(parts));
node.attributes.unshift(newClassAttr);

// In new-enough versions of Ember (>= 3.25 or so), we need to create a
// fake good-enough `loc` whose content will start with `class=` to avoid
// triggering https://github.com/emberjs/ember.js/issues/19392
if (typeof localClassAttr.loc.slice === 'function') {
newClassAttr.loc = localClassAttr.loc.slice({
skipStart: 'local-'.length,
});
}
}

localToPath(node) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-css-modules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-css-modules",
"version": "2.0.0",
"version": "2.0.1",
"description": "CSS Modules for ambitious applications",
"scripts": {
"build": "ember build --environment=production",
Expand Down