Comparing version 0.4.0-alpha.20 to 0.4.0-alpha.21
@@ -39,31 +39,33 @@ import ts from 'typescript'; | ||
const prop = node.properties[i]; | ||
if (prop.initializer) { | ||
const key = prop.name.escapedText || prop.name.text; | ||
const isNumber = prop.initializer.kind === ts.SyntaxKind.FirstLiteralToken; | ||
if (isNumber || | ||
prop.initializer.kind === ts.SyntaxKind.StringLiteral) { | ||
classNames.push(css({ | ||
[key]: isNumber | ||
? Number(prop.initializer.text) | ||
: prop.initializer.text, | ||
})); | ||
if (i < node.properties.length - 1) { | ||
const next = node.properties[i + 1]; | ||
rm(prop.pos, next.pos); | ||
} | ||
else { | ||
rm(prop.pos, node.end - 1); | ||
} | ||
continue; | ||
if (!prop.initializer) { | ||
keepStyled = true; | ||
continue; | ||
} | ||
const key = prop.name.escapedText || prop.name.text; | ||
if (!key) { | ||
keepStyled = true; | ||
continue; | ||
} | ||
const isNumber = prop.initializer.kind === ts.SyntaxKind.FirstLiteralToken; | ||
if (isNumber || | ||
prop.initializer.kind === ts.SyntaxKind.StringLiteral) { | ||
classNames.push(css({ | ||
[key]: isNumber | ||
? Number(prop.initializer.text) | ||
: prop.initializer.text, | ||
})); | ||
if (i < node.properties.length - 1) { | ||
const next = node.properties[i + 1]; | ||
rm(prop.pos, next.pos); | ||
} | ||
if (!keepStyled) { | ||
if ((key[0] === '@' && key[1] === 'm') || key[0] === '&') { | ||
keepStyled = true; | ||
} | ||
else { | ||
rm(prop.pos, node.end - 1); | ||
} | ||
continue; | ||
} | ||
else { | ||
keepStyled = true; | ||
if (!keepStyled) { | ||
if ((key[0] === '@' && key[1] === 'm') || key[0] === '&') { | ||
keepStyled = true; | ||
} | ||
} | ||
remainingProps = true; | ||
} | ||
@@ -82,6 +84,6 @@ if (!keepStyled) { | ||
} | ||
if (!remainingProps) { | ||
rm(node.p.p.pos, node.p.p.end); | ||
} | ||
} | ||
if (!remainingProps) { | ||
rm(node.p.p.pos, node.p.p.end); | ||
} | ||
} | ||
@@ -88,0 +90,0 @@ return; |
{ | ||
"name": "inlines", | ||
"description": "When you just want to use the style prop in React", | ||
"version": "0.4.0-alpha.20", | ||
"version": "0.4.0-alpha.21", | ||
"main": "dist/src/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/src/index.d.ts", |
@@ -49,37 +49,42 @@ import ts from 'typescript' | ||
const prop = node.properties[i] | ||
if (prop.initializer) { | ||
const key = prop.name.escapedText || prop.name.text | ||
const isNumber = | ||
prop.initializer.kind === ts.SyntaxKind.FirstLiteralToken | ||
if ( | ||
isNumber || | ||
prop.initializer.kind === ts.SyntaxKind.StringLiteral | ||
) { | ||
classNames.push( | ||
css({ | ||
[key]: isNumber | ||
? Number(prop.initializer.text) | ||
: prop.initializer.text, | ||
}), | ||
) | ||
if (i < node.properties.length - 1) { | ||
const next = node.properties[i + 1] | ||
rm(prop.pos, next.pos) | ||
} else { | ||
rm(prop.pos, node.end - 1) | ||
} | ||
continue | ||
if (!prop.initializer) { | ||
keepStyled = true | ||
continue | ||
} | ||
const key = prop.name.escapedText || prop.name.text | ||
if (!key) { | ||
keepStyled = true | ||
continue | ||
} | ||
const isNumber = | ||
prop.initializer.kind === ts.SyntaxKind.FirstLiteralToken | ||
if ( | ||
isNumber || | ||
prop.initializer.kind === ts.SyntaxKind.StringLiteral | ||
) { | ||
classNames.push( | ||
css({ | ||
[key]: isNumber | ||
? Number(prop.initializer.text) | ||
: prop.initializer.text, | ||
}), | ||
) | ||
if (i < node.properties.length - 1) { | ||
const next = node.properties[i + 1] | ||
rm(prop.pos, next.pos) | ||
} else { | ||
rm(prop.pos, node.end - 1) | ||
} | ||
continue | ||
} | ||
if (!keepStyled) { | ||
if ((key[0] === '@' && key[1] === 'm') || key[0] === '&') { | ||
keepStyled = true | ||
} | ||
if (!keepStyled) { | ||
if ((key[0] === '@' && key[1] === 'm') || key[0] === '&') { | ||
keepStyled = true | ||
} | ||
} else { | ||
keepStyled = true | ||
} | ||
remainingProps = true | ||
} | ||
@@ -102,6 +107,6 @@ | ||
} | ||
} | ||
if (!remainingProps) { | ||
rm(node.p.p.pos, node.p.p.end) | ||
if (!remainingProps) { | ||
rm(node.p.p.pos, node.p.p.end) | ||
} | ||
} | ||
@@ -108,0 +113,0 @@ } |
38977
1018