Skip to content

Commit

Permalink
Add test verifying that namedspaced JSX attributes are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Mar 26, 2024
1 parent 10e0c19 commit 54f0d43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,12 @@ function transformJavaScript(ast, { env }) {
return
}

// We don't want to support namespaced attributes (e.g. `somens:class`)
// React doesn't support them and most tools don't either
if (typeof node.name.name !== 'string') {
return
}

if (!staticAttrs.has(node.name.name)) {
return
}
Expand Down
1 change: 1 addition & 0 deletions tests/format.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let css = [

let javascript = [
t`;<div class="${yes}" />`,
t`;<div ns:class="${no}" />`,
t`/* <div class="${no}" /> */`,
t`// <div class="${no}" />`,
t`;<div not-class="${no}" />`,
Expand Down

0 comments on commit 54f0d43

Please sign in to comment.