Commit 38a9b387 authored by Romain Courteaud's avatar Romain Courteaud

Release version 0.14.1

onStateChanges bug fixes
parent 07d8ddc6
This diff is collapsed.
This diff is collapsed.
...@@ -1265,27 +1265,43 @@ if (typeof document.contains !== 'function') { ...@@ -1265,27 +1265,43 @@ if (typeof document.contains !== 'function') {
return this.element; return this.element;
}) })
.declareMethod('changeState', function (state_dict) { .declareMethod('changeState', function (state_dict) {
var next_onStateChange = new RSVP.Queue(),
previous_onStateCHange,
context = this;
if (context.hasOwnProperty('__previous_onStateChange')) {
previous_onStateCHange = context.__previous_onStateChange;
next_onStateChange
.push(function () {
return previous_onStateCHange;
})
.push(undefined, function () {
// Run callback even if previous failed
return;
});
}
context.__previous_onStateChange = next_onStateChange;
return next_onStateChange
.push(function () {
var key, var key,
modified = false, modified = false,
previous_cancelled = this.hasOwnProperty('__modification_dict'), previous_cancelled = context.hasOwnProperty('__modification_dict'),
modification_dict, modification_dict;
context = this;
if (previous_cancelled) { if (previous_cancelled) {
modification_dict = this.__modification_dict; modification_dict = context.__modification_dict;
modified = true; modified = true;
} else { } else {
modification_dict = {}; modification_dict = {};
this.__modification_dict = modification_dict;
} }
for (key in state_dict) { for (key in state_dict) {
if (state_dict.hasOwnProperty(key) && if (state_dict.hasOwnProperty(key) &&
(state_dict[key] !== this.state[key])) { (state_dict[key] !== context.state[key])) {
this.state[key] = state_dict[key]; context.state[key] = state_dict[key];
modification_dict[key] = state_dict[key]; modification_dict[key] = state_dict[key];
modified = true; modified = true;
} }
} }
if (modified && this.__state_change_callback !== undefined) { if (modified && context.__state_change_callback !== undefined) {
context.__modification_dict = modification_dict;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return context.__state_change_callback(modification_dict); return context.__state_change_callback(modification_dict);
...@@ -1296,6 +1312,7 @@ if (typeof document.contains !== 'function') { ...@@ -1296,6 +1312,7 @@ if (typeof document.contains !== 'function') {
}); });
} }
}); });
});
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// RenderJSGadget.declareAcquiredMethod // RenderJSGadget.declareAcquiredMethod
......
This diff is collapsed.
{ {
"name": "renderjs", "name": "renderjs",
"version": "0.14.0", "version": "0.14.1",
"description": "RenderJs provides HTML5 gadgets", "description": "RenderJs provides HTML5 gadgets",
"main": "dist/renderjs-latest.js", "main": "dist/renderjs-latest.js",
"dependencies": { "dependencies": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment