Comparing version 1.3.0 to 1.3.1
@@ -10,2 +10,3 @@ const transpileJSX = require('./lib/components'); | ||
* @param {(true|'dom')} [config.quoteProps=false] Whether to surround property names with quotes, e.g., for the Google Closure Compiler. When `dom` is passed, it will only quote props for invoking html components, i.e., those that start with a lowercase letter. Default `false`. | ||
* @param {function} [config.warn] The function to receive warnings, e.g., when destructuring of properties is used on dom elements (for Closure Compiler). | ||
*/ | ||
@@ -43,2 +44,3 @@ const jsx = (input, config = {}) => { | ||
* @prop {(true|'dom')} [quoteProps=false] Whether to surround property names with quotes, e.g., for the Google Closure Compiler. When `dom` is passed, it will only quote props for invoking html components, i.e., those that start with a lowercase letter. Default `false`. | ||
* @prop {function} [warn] The function to receive warnings, e.g., when destructuring of properties is used on dom elements (for Closure Compiler). | ||
*/ |
@@ -18,3 +18,3 @@ let detectJSX = require('@a-la/detect-jsx'); if (detectJSX && detectJSX.__esModule) detectJSX = detectJSX.default; | ||
const transpileJSX = (input, config = {}) => { | ||
const { quoteProps } = config | ||
const { quoteProps, warn } = config | ||
const position = detectJSX(input) | ||
@@ -25,5 +25,5 @@ if (position === null) return input | ||
const { props = '', content, tagName, string: { length } } = extract(s) | ||
const children = parseContent(content, quoteProps) | ||
const children = parseContent(content, quoteProps, warn) | ||
const { obj, destructuring } = getProps(props) | ||
const f = pragma(tagName, obj, children, destructuring, quoteProps) | ||
const f = pragma(tagName, obj, children, destructuring, quoteProps, warn) | ||
const res = replaceChunk(input, position, length, f) | ||
@@ -52,3 +52,3 @@ // find another one one | ||
*/ | ||
const parseContent = (content, quoteProps = false) => { | ||
const parseContent = (content, quoteProps = false, warn) => { | ||
if (!content) return [] | ||
@@ -62,4 +62,4 @@ // const C = content | ||
const { obj, destructuring } = getProps(props) | ||
const children = parseContent(part, quoteProps) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps) | ||
const children = parseContent(part, quoteProps, warn) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps, warn) | ||
return [...acc, p] | ||
@@ -72,4 +72,4 @@ } | ||
const { obj, destructuring } = getProps(props) | ||
const children = parseContent(part, quoteProps) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps) | ||
const children = parseContent(part, quoteProps, warn) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps, warn) | ||
const strBefore = string.slice(0, j) | ||
@@ -76,0 +76,0 @@ const strAfter = string.slice(j + length) |
@@ -139,3 +139,3 @@ let mismatch = require('mismatch'); if (mismatch && mismatch.__esModule) mismatch = mismatch.default; | ||
*/ | ||
const pragma = (tagName, props = {}, children = [], destructuring = [], quoteProps = false) => { | ||
const pragma = (tagName, props = {}, children = [], destructuring = [], quoteProps = false, warn) => { | ||
const cn = isComponentName(tagName) | ||
@@ -155,4 +155,4 @@ const tn = cn ? tagName : `'${tagName}'` | ||
const qp = cn && quoteProps == 'dom' ? false : quoteProps | ||
if (!cn && destructuring.length && !quoteProps) { | ||
console.warn('JSX: destructuring %s is used without quoted props on HTML %s\nMake sure to pass props in quotes if using Closure Compiler.', destructuring.join(' '), tagName) | ||
if (!cn && destructuring.length && (!quoteProps || quoteProps == 'dom')) { | ||
warn && warn(`JSX: destructuring ${destructuring.join(' ')} is used without quoted props on HTML ${tagName}.`) | ||
} | ||
@@ -159,0 +159,0 @@ const pr = makeObjectBody(props, destructuring, qp) |
@@ -0,1 +1,7 @@ | ||
## 7 February 2019 | ||
### 1.3.1 | ||
- [feature] Pass `warn` function to correctly warn of destructuring on dom elements for GCC. | ||
## 6 February 2019 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "@a-la/jsx", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "The JSX Transform For ÀLaMode And Other Packages.", | ||
@@ -48,4 +48,4 @@ "main": "build/index.js", | ||
"@wrote/read": "1.0.2", | ||
"alamode": "1.6.1", | ||
"documentary": "1.20.1", | ||
"alamode": "1.7.3", | ||
"documentary": "1.21.1", | ||
"eslint-config-artdeco": "1.0.1", | ||
@@ -58,4 +58,4 @@ "yarn-s": "1.1.0", | ||
"mismatch": "1.0.3", | ||
"restream": "3.4.1" | ||
"restream": "3.5.0" | ||
} | ||
} |
@@ -10,2 +10,3 @@ import transpileJSX from './lib/components' | ||
* @param {(true|'dom')} [config.quoteProps=false] Whether to surround property names with quotes, e.g., for the Google Closure Compiler. When `dom` is passed, it will only quote props for invoking html components, i.e., those that start with a lowercase letter. Default `false`. | ||
* @param {function} [config.warn] The function to receive warnings, e.g., when destructuring of properties is used on dom elements (for Closure Compiler). | ||
*/ | ||
@@ -43,2 +44,3 @@ const jsx = (input, config = {}) => { | ||
* @prop {(true|'dom')} [quoteProps=false] Whether to surround property names with quotes, e.g., for the Google Closure Compiler. When `dom` is passed, it will only quote props for invoking html components, i.e., those that start with a lowercase letter. Default `false`. | ||
* @prop {function} [warn] The function to receive warnings, e.g., when destructuring of properties is used on dom elements (for Closure Compiler). | ||
*/ |
@@ -18,3 +18,3 @@ import detectJSX from '@a-la/detect-jsx' | ||
const transpileJSX = (input, config = {}) => { | ||
const { quoteProps } = config | ||
const { quoteProps, warn } = config | ||
const position = detectJSX(input) | ||
@@ -25,5 +25,5 @@ if (position === null) return input | ||
const { props = '', content, tagName, string: { length } } = extract(s) | ||
const children = parseContent(content, quoteProps) | ||
const children = parseContent(content, quoteProps, warn) | ||
const { obj, destructuring } = getProps(props) | ||
const f = pragma(tagName, obj, children, destructuring, quoteProps) | ||
const f = pragma(tagName, obj, children, destructuring, quoteProps, warn) | ||
const res = replaceChunk(input, position, length, f) | ||
@@ -52,3 +52,3 @@ // find another one one | ||
*/ | ||
export const parseContent = (content, quoteProps = false) => { | ||
export const parseContent = (content, quoteProps = false, warn) => { | ||
if (!content) return [] | ||
@@ -62,4 +62,4 @@ // const C = content | ||
const { obj, destructuring } = getProps(props) | ||
const children = parseContent(part, quoteProps) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps) | ||
const children = parseContent(part, quoteProps, warn) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps, warn) | ||
return [...acc, p] | ||
@@ -72,4 +72,4 @@ } | ||
const { obj, destructuring } = getProps(props) | ||
const children = parseContent(part, quoteProps) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps) | ||
const children = parseContent(part, quoteProps, warn) | ||
const p = pragma(tagName, obj, children, destructuring, quoteProps, warn) | ||
const strBefore = string.slice(0, j) | ||
@@ -76,0 +76,0 @@ const strAfter = string.slice(j + length) |
@@ -139,3 +139,3 @@ import mismatch from 'mismatch' | ||
*/ | ||
export const pragma = (tagName, props = {}, children = [], destructuring = [], quoteProps = false) => { | ||
export const pragma = (tagName, props = {}, children = [], destructuring = [], quoteProps = false, warn) => { | ||
const cn = isComponentName(tagName) | ||
@@ -155,4 +155,4 @@ const tn = cn ? tagName : `'${tagName}'` | ||
const qp = cn && quoteProps == 'dom' ? false : quoteProps | ||
if (!cn && destructuring.length && !quoteProps) { | ||
console.warn('JSX: destructuring %s is used without quoted props on HTML %s\nMake sure to pass props in quotes if using Closure Compiler.', destructuring.join(' '), tagName) | ||
if (!cn && destructuring.length && (!quoteProps || quoteProps == 'dom')) { | ||
warn && warn(`JSX: destructuring ${destructuring.join(' ')} is used without quoted props on HTML ${tagName}.`) | ||
} | ||
@@ -159,0 +159,0 @@ const pr = makeObjectBody(props, destructuring, qp) |
45468
941
+ Added@artdeco/clean-stack@1.0.1(transitive)
+ Addedrestream@3.5.0(transitive)
- Removed@artdeco/clean-stack@1.0.0(transitive)
- Removedrestream@3.4.1(transitive)
Updatedrestream@3.5.0