Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuhl committed Dec 13, 2017
1 parent 5e1fb26 commit 465b95e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 7.2.0
- Add usePureComponent option [PR357](https://github.com/i18next/react-i18next/pull/357)
- Render empty string on empty string as Trans child [PR364](https://github.com/i18next/react-i18next/pull/364)

### 7.1.1
- fixes: bring back Trans component t fc from context

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-i18next",
"version": "7.1.1",
"version": "7.2.0",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"jsnext:main": "dist/es/index.js",
Expand Down
75 changes: 74 additions & 1 deletion react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,76 @@ var slicedToArray = function () {
};
}();

/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule shallowEqual
* @typechecks
* @flow
*/

/* eslint-disable no-self-compare */

var hasOwnProperty = Object.prototype.hasOwnProperty;

/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
// Added the nonzero y check to make Flow happy, but it is redundant
return x !== 0 || y !== 0 || 1 / x === 1 / y;
}
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}

/**
* Performs equality by iterating through keys on an object and returning false
* when any key has values which are not strictly equal between the arguments.
* Returns true when the values of all keys are strictly equal.
*/
function shallowEqual(objA, objB) {
if (is(objA, objB)) {
return true;
}

if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
return false;
}

var keysA = Object.keys(objA);
var keysB = Object.keys(objB);

if (keysA.length !== keysB.length) {
return false;
}

// Test for A's keys different from B.
for (var i = 0; i < keysA.length; i++) {
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}

return true;
}

var defaultOptions = {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
nsMode: 'default',
usePureComponent: false
};

var i18n = void 0;
Expand Down Expand Up @@ -558,6 +621,15 @@ function translate(namespaces) {
}

createClass(Translate, [{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps) {
if (!this.options.usePureComponent) {
return true;
}

return !shallowEqual(this.props, nextProps);
}
}, {
key: 'getWrappedInstance',
value: function getWrappedInstance() {
if (!this.options.withRef) {
Expand Down Expand Up @@ -957,6 +1029,7 @@ function nodesToString(mem, children, index) {
}

function renderNodes(children, targetString, i18n) {
if (targetString === "") return [];

// parse ast from string with additional wrapper tag
// -> avoids issues in parser removing prepending text nodes
Expand Down
2 changes: 1 addition & 1 deletion react-i18next.min.js

Large diffs are not rendered by default.

0 comments on commit 465b95e

Please sign in to comment.