What This Rule Does
This rule detects instances in JavaScript where a query selector targets an element using an exact string match for the class
attribute that includes extra whitespace.
Starting Spring ’25, Salesforce no longer renders extra spaces between classes or empty class=""
or style=""
attributes, which means selectors that depend on whitespace or exact class
string matches can break.
Why It Matters
Salesforce’s new rendering behavior removes extra whitespace in class attributes and eliminates empty class/style attributes entirely. This means that selectors like:
document.querySelector('[class=" highlight yellow "]');
will fail to find matching elements in the DOM. These queries rely on the presence of whitespace that no longer exists.
Instead, developers should use more flexible and reliable selectors like:
document.querySelector('.highlight.yellow');
How It Works
Scope: JavaScript source files within LWC modules
Match: Any querySelector or DOM method that looks for an exact
[class="..."]
selector with internal or trailing whitespaceWhy: These selectors will no longer match the DOM due to changes in how Salesforce strips whitespace