Add a 'throwIfNamespace' option for JSX transform (#6563)

* Added tests for ifThrowNamespace flag

* JSX transformator could work with XMLNamespaces (ifThrowNamespace flag)

* Use template literal instead

* Attempt to reword the message

* Added docs

* Reworded docs

* Reworded docs

* Fixed missing space in error message
This commit is contained in:
Jakub Beneš
2017-10-29 02:44:15 +02:00
committed by Henry Zhu
parent 9ac326b075
commit 04d2c030be
10 changed files with 58 additions and 7 deletions

View File

@@ -78,7 +78,8 @@ With options:
{
"plugins": [
["@babel/transform-react-jsx", {
"pragma": "dom" // default pragma is React.createElement
"pragma": "dom", // default pragma is React.createElement
"throwIfNamespace": false // defaults to true
}]
]
}
@@ -113,3 +114,13 @@ Note that the `@jsx React.DOM` pragma has been deprecated as of React v0.12
`boolean`, defaults to `false`.
When spreading props, use `Object.assign` directly instead of Babel's extend helper.
### `throwIfNamespace`
`boolean`, defaults to `true`.
Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
<f:image />
Though the JSX spec allows this, it is disabled by default since React's JSX does not currently have support for it.