Always serialize the DOM in one way.

pull/1/head
Yann Flory 9 years ago
parent e207d8b579
commit 9683fd9aec

@ -44,6 +44,16 @@ define([
return true;
};
/* catch `type="_moz"` before it goes over the wire */
var brFilter = function (hj) {
if (hj[1].type === '_moz') { hj[1].type = undefined; }
return hj;
};
var stringifyDOM = function (dom) {
return JSON.stringify(Hyperjson.fromDOM(dom, isNotMagicLine, brFilter));
};
var andThen = function (Ckeditor) {
/* This is turned off because we prefer that the channel name
be chosen by the server, not generated by the client.
@ -189,7 +199,7 @@ define([
var realtimeOptions = {
// provide initialstate...
initialState: JSON.stringify(Hyperjson.fromDOM(inner, isNotMagicLine)),
initialState: stringifyDOM(inner) || '{}',
// the websocket URL
websocketURL: Config.websocketURL,
@ -241,8 +251,7 @@ define([
// Build a new stringified Chainpad hyperjson without metadata to compare with the one build from the dom
shjson = JSON.stringify(hjson);
var hjson2 = Hyperjson.fromDOM(inner);
var shjson2 = JSON.stringify(hjson2);
var shjson2 = stringifyDOM(inner);
if (shjson2 !== shjson) {
console.error("shjson2 !== shjson");
module.realtimeInput.patchText(shjson2);
@ -283,12 +292,6 @@ define([
var rti = module.realtimeInput = realtimeInput.start(realtimeOptions);
/* catch `type="_moz"` before it goes over the wire */
var brFilter = function (hj) {
if (hj[1].type === '_moz') { hj[1].type = undefined; }
return hj;
};
/* It's incredibly important that you assign 'rti.onLocal'
It's used inside of realtimeInput to make sure that all changes
make it into chainpad.

Loading…
Cancel
Save