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,36 +1265,53 @@ if (typeof document.contains !== 'function') { ...@@ -1265,36 +1265,53 @@ if (typeof document.contains !== 'function') {
return this.element; return this.element;
}) })
.declareMethod('changeState', function (state_dict) { .declareMethod('changeState', function (state_dict) {
var key, var next_onStateChange = new RSVP.Queue(),
modified = false, previous_onStateCHange,
previous_cancelled = this.hasOwnProperty('__modification_dict'),
modification_dict,
context = this; context = this;
if (previous_cancelled) { if (context.hasOwnProperty('__previous_onStateChange')) {
modification_dict = this.__modification_dict; previous_onStateCHange = context.__previous_onStateChange;
modified = true; next_onStateChange
} else {
modification_dict = {};
this.__modification_dict = modification_dict;
}
for (key in state_dict) {
if (state_dict.hasOwnProperty(key) &&
(state_dict[key] !== this.state[key])) {
this.state[key] = state_dict[key];
modification_dict[key] = state_dict[key];
modified = true;
}
}
if (modified && this.__state_change_callback !== undefined) {
return new RSVP.Queue()
.push(function () { .push(function () {
return context.__state_change_callback(modification_dict); return previous_onStateCHange;
}) })
.push(function (result) { .push(undefined, function () {
delete context.__modification_dict; // Run callback even if previous failed
return result; return;
}); });
} }
context.__previous_onStateChange = next_onStateChange;
return next_onStateChange
.push(function () {
var key,
modified = false,
previous_cancelled = context.hasOwnProperty('__modification_dict'),
modification_dict;
if (previous_cancelled) {
modification_dict = context.__modification_dict;
modified = true;
} else {
modification_dict = {};
}
for (key in state_dict) {
if (state_dict.hasOwnProperty(key) &&
(state_dict[key] !== context.state[key])) {
context.state[key] = state_dict[key];
modification_dict[key] = state_dict[key];
modified = true;
}
}
if (modified && context.__state_change_callback !== undefined) {
context.__modification_dict = modification_dict;
return new RSVP.Queue()
.push(function () {
return context.__state_change_callback(modification_dict);
})
.push(function (result) {
delete context.__modification_dict;
return result;
});
}
});
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
......
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