Skip to content

Commit

Permalink
postpone usage of newer ES syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Aug 11, 2023
1 parent 91b4bf0 commit a171f5e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 13.1.2

- postpone usage of newer ES syntax

### 13.1.1

- Render all children regardless of type when using i18nIsDynamicList prop [1661](https://github.com/i18next/react-i18next/pull/1661)
Expand Down
8 changes: 4 additions & 4 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
function getChildren(node) {
if (!node) return [];
const children = node.props ? node.props.children : node.children;
return node.props?.i18nIsDynamicList ? getAsArray(children) : children;
return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children;
}
function hasValidReactChildren(children) {
if (Object.prototype.toString.call(children) !== '[object Array]') return false;
Expand Down Expand Up @@ -357,7 +357,7 @@
function renderInner(child, node, rootReactNode) {
const childs = getChildren(child);
const mappedChildren = mapAST(childs, node.children, rootReactNode);
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props?.i18nIsDynamicList ? childs : mappedChildren;
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props && child.props.i18nIsDynamicList ? childs : mappedChildren;
}
function pushTranslatedJSX(child, inner, mem, i, isVoid) {
if (child.dummy) {
Expand Down Expand Up @@ -387,8 +387,8 @@
const translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
if (node.type === 'tag') {
let tmp = reactNodes[parseInt(node.name, 10)];
if (rootReactNode.length === 1) tmp ||= rootReactNode[0][node.name];
tmp ||= {};
if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name];
if (!tmp) tmp = {};
const child = Object.keys(node.attrs).length !== 0 ? mergeProps({
props: node.attrs
}, tmp) : tmp;
Expand Down
Loading

0 comments on commit a171f5e

Please sign in to comment.