i18next-parser
Advanced tools
Comparing version 3.5.0 to 3.6.0
# Changelog | ||
# 3.5.0 - latest | ||
# 3.6.0 - latest | ||
- Fix a conflict in jsx lexer #254 | ||
# 3.5.0 | ||
- Stop trying to parse directories #252 | ||
@@ -6,0 +10,0 @@ |
@@ -129,11 +129,11 @@ 'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();var _javascriptLexer = require('./javascript-lexer');var _javascriptLexer2 = _interopRequireDefault(_javascriptLexer); | ||
case 'tag': | ||
var elementName = | ||
var useTagName = | ||
child.isBasic && | ||
_this4.transSupportBasicHtmlNodes && | ||
_this4.transKeepBasicHtmlNodesFor.includes(child.name) ? | ||
child.name : | ||
index; | ||
return '<' + elementName + '>' + elemsToString( | ||
child.children) + '</' + | ||
elementName + '>'; | ||
_this4.transKeepBasicHtmlNodesFor.includes(child.name); | ||
var elementName = useTagName ? child.name : index; | ||
var childrenString = elemsToString(child.children); | ||
return childrenString || !(useTagName && child.selfClosing) ? '<' + | ||
elementName + '>' + childrenString + '</' + elementName + '>' : '<' + | ||
elementName + ' />'; | ||
default: | ||
@@ -169,3 +169,4 @@ throw new Error('Unknown parsed content: ' + child.type);} | ||
name: name, | ||
isBasic: isBasic }; | ||
isBasic: isBasic, | ||
selfClosing: child.kind === ts.SyntaxKind.JsxSelfClosingElement }; | ||
@@ -172,0 +173,0 @@ } else if (child.kind === ts.SyntaxKind.JsxExpression) { |
@@ -5,3 +5,3 @@ { | ||
"name": "i18next-parser", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "dist/index.js", |
@@ -14,1 +14,2 @@ ### Why am I submitting this PR | ||
- [ ] documentation is changed or added | ||
- [ ] I ran `yarn build` to compile and prettify the code |
@@ -129,11 +129,11 @@ import JavascriptLexer from './javascript-lexer' | ||
case 'tag': | ||
const elementName = | ||
const useTagName = | ||
child.isBasic && | ||
this.transSupportBasicHtmlNodes && | ||
this.transKeepBasicHtmlNodesFor.includes(child.name) | ||
? child.name | ||
: index | ||
return `<${elementName}>${elemsToString( | ||
child.children | ||
)}</${elementName}>` | ||
const elementName = useTagName ? child.name : index | ||
const childrenString = elemsToString(child.children) | ||
return childrenString || !(useTagName && child.selfClosing) | ||
? `<${elementName}>${childrenString}</${elementName}>` | ||
: `<${elementName} />` | ||
default: | ||
@@ -170,2 +170,3 @@ throw new Error('Unknown parsed content: ' + child.type) | ||
isBasic, | ||
selfClosing: child.kind === ts.SyntaxKind.JsxSelfClosingElement, | ||
} | ||
@@ -172,0 +173,0 @@ } else if (child.kind === ts.SyntaxKind.JsxExpression) { |
@@ -320,4 +320,21 @@ import { assert } from 'chai' | ||
}) | ||
it('keeps self-closing tags untouched when transSupportBasicHtmlNodes is true', (done) => { | ||
const Lexer = new JsxLexer({ transSupportBasicHtmlNodes: true }) | ||
const content = '<Trans>a<br />b</Trans>' | ||
assert.equal(Lexer.extract(content)[0].defaultValue, 'a<br />b') | ||
done() | ||
}) | ||
it('keeps empty tag untouched when transSupportBasicHtmlNodes is true', (done) => { | ||
const Lexer = new JsxLexer({ transSupportBasicHtmlNodes: true }) | ||
const content = '<Trans>a<strong></strong>b</Trans>' | ||
assert.equal( | ||
Lexer.extract(content)[0].defaultValue, | ||
'a<strong></strong>b' | ||
) | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
411018
5280