Skip to content

Commit

Permalink
✨ release(patch): v4.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Aug 23, 2016
1 parent 221d015 commit 3e1bf8d
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 69 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="4.2.3"></a>
## [4.2.3](https://github.com/kazupon/vue-i18n/compare/v4.2.2...v4.2.3) (2016-08-23)


### :chart_with_upwards_trend: Performance Fixes

* improve re-rendering cost when change the lang ([0707338](https://github.com/kazupon/vue-i18n/commit/0707338))



<a name="4.2.2"></a>
## [4.2.2](https://github.com/kazupon/vue-i18n/compare/v4.2.1...v4.2.2) (2016-08-15)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Internationalization plugin of Vue.js
jsdelivr

```html
<script src="https://cdn.jsdelivr.net/vue.i18n/4.2.2/vue-i18n.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue.i18n/4.2.3/vue-i18n.min.js"></script>
```

### NPM
Expand Down
58 changes: 26 additions & 32 deletions dist/vue-i18n.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-i18n v4.2.2
* vue-i18n v4.2.3
* (c) 2016 kazuya kawaguchi
* Released under the MIT License.
*/
Expand Down Expand Up @@ -124,49 +124,47 @@ function isPromise(p) {
return p && typeof p.then === 'function';
}

function Override (Vue, langVM) {
function Override (Vue, langVM, version) {
function update(vm) {
if (version > 1) {
vm.$forceUpdate();
} else {
var i = vm._watchers.length;
while (i--) {
vm._watchers[i].update(true); // shallow updates
}
}
}

// override _init
var init = Vue.prototype._init;
Vue.prototype._init = function (options) {
var _this = this;

options = options || {};
var root = options._parent || options.parent || this;
var lang = root.$lang;
init.call(this, options);

if (lang) {
this.$lang = lang;
} else {
if (!this.$parent) {
// root
this.$lang = langVM;
this._langUnwatch = this.$lang.$watch('lang', function (a, b) {
update(_this);
});
}

this._langUnwatch = this.$lang.$watch('lang', function (a, b) {
update(_this);
});

init.call(this, options);
};

// override _destroy
var destroy = Vue.prototype._destroy;
Vue.prototype._destroy = function () {
if (this._langUnwatch) {
if (!this.$parent && this._langUnwatch) {
this._langUnwatch();
this._langUnwatch = null;
this.$lang = null;
}

this.$lang = null;
destroy.apply(this, arguments);
};
}

function update(vm) {
var i = vm._watchers.length;
while (i--) {
vm._watchers[i].update(true); // shallow updates
}
}

/**
* Observer
*/
Expand Down Expand Up @@ -217,12 +215,8 @@ function Config (Vue, langVM, lang) {
});

return function computedGetter() {
if (watcher.dirty) {
watcher.evaluate();
}
if (Dep.target) {
watcher.depend();
}
watcher.dirty && watcher.evaluate();
Dep.target && watcher.depend();
return watcher.value;
};
}
Expand Down Expand Up @@ -844,10 +838,10 @@ function plugin(Vue) {
}

var lang = 'en';

setupLangVM(Vue, lang);

Asset(Vue);
Override(Vue, langVM);
Override(Vue, langVM, version);
Config(Vue, langVM, lang);
Extend(Vue);
}
Expand All @@ -861,7 +855,7 @@ function setupLangVM(Vue, lang) {
Vue.config.silent = silent;
}

plugin.version = '4.2.2';
plugin.version = '4.2.3';

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(plugin);
Expand Down
58 changes: 26 additions & 32 deletions dist/vue-i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-i18n v4.2.2
* vue-i18n v4.2.3
* (c) 2016 kazuya kawaguchi
* Released under the MIT License.
*/
Expand Down Expand Up @@ -128,49 +128,47 @@
return p && typeof p.then === 'function';
}

function Override (Vue, langVM) {
function Override (Vue, langVM, version) {
function update(vm) {
if (version > 1) {
vm.$forceUpdate();
} else {
var i = vm._watchers.length;
while (i--) {
vm._watchers[i].update(true); // shallow updates
}
}
}

// override _init
var init = Vue.prototype._init;
Vue.prototype._init = function (options) {
var _this = this;

options = options || {};
var root = options._parent || options.parent || this;
var lang = root.$lang;
init.call(this, options);

if (lang) {
this.$lang = lang;
} else {
if (!this.$parent) {
// root
this.$lang = langVM;
this._langUnwatch = this.$lang.$watch('lang', function (a, b) {
update(_this);
});
}

this._langUnwatch = this.$lang.$watch('lang', function (a, b) {
update(_this);
});

init.call(this, options);
};

// override _destroy
var destroy = Vue.prototype._destroy;
Vue.prototype._destroy = function () {
if (this._langUnwatch) {
if (!this.$parent && this._langUnwatch) {
this._langUnwatch();
this._langUnwatch = null;
this.$lang = null;
}

this.$lang = null;
destroy.apply(this, arguments);
};
}

function update(vm) {
var i = vm._watchers.length;
while (i--) {
vm._watchers[i].update(true); // shallow updates
}
}

/**
* Observer
*/
Expand Down Expand Up @@ -221,12 +219,8 @@
});

return function computedGetter() {
if (watcher.dirty) {
watcher.evaluate();
}
if (Dep.target) {
watcher.depend();
}
watcher.dirty && watcher.evaluate();
Dep.target && watcher.depend();
return watcher.value;
};
}
Expand Down Expand Up @@ -848,10 +842,10 @@
}

var lang = 'en';

setupLangVM(Vue, lang);

Asset(Vue);
Override(Vue, langVM);
Override(Vue, langVM, version);
Config(Vue, langVM, lang);
Extend(Vue);
}
Expand All @@ -865,7 +859,7 @@
Vue.config.silent = silent;
}

plugin.version = '4.2.2';
plugin.version = '4.2.3';

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(plugin);
Expand Down
4 changes: 2 additions & 2 deletions dist/vue-i18n.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-i18n",
"description": "Internationalization plugin for Vue.js",
"version": "4.2.2",
"version": "4.2.3",
"author": {
"name": "kazuya kawaguchi",
"email": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function setupLangVM (Vue, lang) {
Vue.config.silent = silent
}

plugin.version = '4.2.2'
plugin.version = '4.2.3'

export default plugin

Expand Down

0 comments on commit 3e1bf8d

Please sign in to comment.