Commit c5ec7d2e authored by Romain Courteaud's avatar Romain Courteaud

Explicitely make local renderJS parameter non JSLint compliant.

It may help developper to see all properties which are not part of the API.
parent 76805e06
...@@ -78,12 +78,12 @@ module.exports = function (grunt) { ...@@ -78,12 +78,12 @@ module.exports = function (grunt) {
'QUnit', 'QUnit',
'renderJS', 'renderJS',
'rJS', 'rJS',
'RenderJSGadget', '__RenderJSGadget',
'sinon', 'sinon',
'RSVP', 'RSVP',
'DOMParser', 'DOMParser',
'RenderJSIframeGadget', '__RenderJSIframeGadget',
'RenderJSEmbeddedGadget' '__RenderJSEmbeddedGadget'
] ]
} }
}, },
......
/*global ace */ /*global ace */
/*jslint nomen: true*/
(function (window, rJS) { (function (window, rJS) {
"use strict"; "use strict";
...@@ -12,7 +13,7 @@ ...@@ -12,7 +13,7 @@
}); });
gk.ready(function (g) { gk.ready(function (g) {
g.editor = ace.edit(g.element.getElementsByTagName('div')[0]); g.editor = ace.edit(g.__element.getElementsByTagName('div')[0]);
g.editor.setTheme("ace/theme/monokai"); g.editor.setTheme("ace/theme/monokai");
}); });
......
/*jslint nomen: true*/
(function (window, rJS) { (function (window, rJS) {
"use strict"; "use strict";
...@@ -11,11 +12,11 @@ ...@@ -11,11 +12,11 @@
var gk = rJS(window); var gk = rJS(window);
gk.declareMethod('setContent', function (value) { gk.declareMethod('setContent', function (value) {
this.element.getElementsByTagName('textarea')[0].value = this.__element.getElementsByTagName('textarea')[0].value =
escape_text(value); escape_text(value);
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
return this.element.getElementsByTagName('textarea')[0].value; return this.__element.getElementsByTagName('textarea')[0].value;
}); });
}(window, rJS)); }(window, rJS));
/*jslint nomen: true*/
(function (window, rJS, $) { (function (window, rJS, $) {
"use strict"; "use strict";
...@@ -5,13 +6,13 @@ ...@@ -5,13 +6,13 @@
gk.declareMethod('setContent', function (value) { gk.declareMethod('setContent', function (value) {
// return this.context.find('textarea').val(escape_text(value)); // return this.context.find('textarea').val(escape_text(value));
return $(this.element).find('#textarea-b').jqteVal(value); return $(this.__element).find('#textarea-b').jqteVal(value);
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
return $(this.element).find('#textarea-b').val(); return $(this.__element).find('#textarea-b').val();
}); });
gk.ready(function (g) { gk.ready(function (g) {
$(g.element).find("#textarea-b").jqte(); $(g.__element).find("#textarea-b").jqte();
}); });
}(window, rJS, jQuery)); }(window, rJS, jQuery));
/*global console */ /*global console */
/*jslint nomen: true*/
(function (window, $, rJS, RSVP) { (function (window, $, rJS, RSVP) {
"use strict"; "use strict";
...@@ -6,8 +7,8 @@ ...@@ -6,8 +7,8 @@
var editor = all_param[0], var editor = all_param[0],
io = all_param[1], io = all_param[1],
id = all_param[2]; id = all_param[2];
$(io.element).trigger('create'); $(io.__element).trigger('create');
$(editor.element).trigger('create'); $(editor.__element).trigger('create');
// .then(function (element) { // .then(function (element) {
// element.trigger('create'); // element.trigger('create');
// }); // });
...@@ -56,7 +57,7 @@ ...@@ -56,7 +57,7 @@
]) ])
.then(function (all_param) { .then(function (all_param) {
i_c.empty(); i_c.empty();
i_c[0].appendChild(all_param[1].element); i_c[0].appendChild(all_param[1].__element);
return attachIOToEditor(all_param); return attachIOToEditor(all_param);
}) })
.fail(handleError); .fail(handleError);
...@@ -64,8 +65,8 @@ ...@@ -64,8 +65,8 @@
} }
rJS(window).ready(function (g) { rJS(window).ready(function (g) {
var editor_a_context = $(g.element).find(".editor_a").last(), var editor_a_context = $(g.__element).find(".editor_a").last(),
io_a_context = $(g.element).find(".editor_a_safe").last(); io_a_context = $(g.__element).find(".editor_a_safe").last();
// editor_b_context = g.context.find(".editor_b").last(), // editor_b_context = g.context.find(".editor_b").last(),
// io_b_context = g.context.find(".editor_b_safe").last(); // io_b_context = g.context.find(".editor_b_safe").last();
...@@ -84,7 +85,7 @@ ...@@ -84,7 +85,7 @@
]); ]);
}) })
.then(function (all_list) { .then(function (all_list) {
var panel_context = $(g.element).find(".bare_panel"), var panel_context = $(g.__element).find(".bare_panel"),
editor_list = all_list[0], editor_list = all_list[0],
io_list = all_list[1], io_list = all_list[1],
editor_definition, editor_definition,
...@@ -102,7 +103,7 @@ ...@@ -102,7 +103,7 @@
]) ])
.then(function (all_param) { .then(function (all_param) {
io_a_context.empty(); io_a_context.empty();
io_a_context[0].appendChild(all_param[1].element); io_a_context[0].appendChild(all_param[1].__element);
return attachIOToEditor(all_param); return attachIOToEditor(all_param);
}) })
.then(function () { .then(function () {
......
/*! RenderJs */ /*! RenderJs */
/*jslint nomen: true*/
/* /*
* renderJs - Generic Gadget library renderer. * renderJs - Generic Gadget library renderer.
...@@ -22,22 +23,22 @@ ...@@ -22,22 +23,22 @@
return new RenderJSGadget(); return new RenderJSGadget();
} }
} }
RenderJSGadget.prototype.title = ""; RenderJSGadget.prototype.__title = "";
RenderJSGadget.prototype.interface_list = []; RenderJSGadget.prototype.__interface_list = [];
RenderJSGadget.prototype.path = ""; RenderJSGadget.prototype.__path = "";
RenderJSGadget.prototype.html = ""; RenderJSGadget.prototype.__html = "";
RenderJSGadget.prototype.required_css_list = []; RenderJSGadget.prototype.__required_css_list = [];
RenderJSGadget.prototype.required_js_list = []; RenderJSGadget.prototype.__required_js_list = [];
RSVP.EventTarget.mixin(RenderJSGadget.prototype); RSVP.EventTarget.mixin(RenderJSGadget.prototype);
function clearGadgetInternalParameters(g) { function clearGadgetInternalParameters(g) {
g.sub_gadget_dict = {}; g.__sub_gadget_dict = {};
} }
RenderJSGadget.ready_list = [clearGadgetInternalParameters]; RenderJSGadget.__ready_list = [clearGadgetInternalParameters];
RenderJSGadget.ready = function (callback) { RenderJSGadget.ready = function (callback) {
this.ready_list.push(callback); this.__ready_list.push(callback);
return this; return this;
}; };
...@@ -61,30 +62,30 @@ ...@@ -61,30 +62,30 @@
RenderJSGadget RenderJSGadget
.declareMethod('getInterfaceList', function () { .declareMethod('getInterfaceList', function () {
// Returns the list of gadget prototype // Returns the list of gadget prototype
return this.interface_list; return this.__interface_list;
}) })
.declareMethod('getRequiredCSSList', function () { .declareMethod('getRequiredCSSList', function () {
// Returns a list of CSS required by the gadget // Returns a list of CSS required by the gadget
return this.required_css_list; return this.__required_css_list;
}) })
.declareMethod('getRequiredJSList', function () { .declareMethod('getRequiredJSList', function () {
// Returns a list of JS required by the gadget // Returns a list of JS required by the gadget
return this.required_js_list; return this.__required_js_list;
}) })
.declareMethod('getPath', function () { .declareMethod('getPath', function () {
// Returns the path of the code of a gadget // Returns the path of the code of a gadget
return this.path; return this.__path;
}) })
.declareMethod('getTitle', function () { .declareMethod('getTitle', function () {
// Returns the title of a gadget // Returns the title of a gadget
return this.title; return this.__title;
}) })
.declareMethod('getElement', function () { .declareMethod('getElement', function () {
// Returns the DOM Element of a gadget // Returns the DOM Element of a gadget
if (this.element === undefined) { if (this.__element === undefined) {
throw new Error("No element defined"); throw new Error("No element defined");
} }
return this.element; return this.__element;
}) })
.declareMethod('acquire', function () { .declareMethod('acquire', function () {
var gadget = this, var gadget = this,
...@@ -115,7 +116,7 @@ ...@@ -115,7 +116,7 @@
} }
RenderJSGadget.call(this); RenderJSGadget.call(this);
} }
RenderJSEmbeddedGadget.ready_list = RenderJSGadget.ready_list.slice(); RenderJSEmbeddedGadget.__ready_list = RenderJSGadget.__ready_list.slice();
RenderJSEmbeddedGadget.ready = RenderJSEmbeddedGadget.ready =
RenderJSGadget.ready; RenderJSGadget.ready;
RenderJSEmbeddedGadget.prototype = new RenderJSGadget(); RenderJSEmbeddedGadget.prototype = new RenderJSGadget();
...@@ -143,12 +144,12 @@ ...@@ -143,12 +144,12 @@
// Get the gadget class and instanciate it // Get the gadget class and instanciate it
.push(function (Klass) { .push(function (Klass) {
var i, var i,
template_node_list = Klass.template_element.body.childNodes; template_node_list = Klass.__template_element.body.childNodes;
gadget_loading_klass = Klass; gadget_loading_klass = Klass;
gadget_instance = new Klass(); gadget_instance = new Klass();
gadget_instance.element = options.element; gadget_instance.__element = options.element;
for (i = 0; i < template_node_list.length; i += 1) { for (i = 0; i < template_node_list.length; i += 1) {
gadget_instance.element.appendChild( gadget_instance.__element.appendChild(
template_node_list[i].cloneNode(true) template_node_list[i].cloneNode(true)
); );
} }
...@@ -186,7 +187,7 @@ ...@@ -186,7 +187,7 @@
} }
RenderJSGadget.call(this); RenderJSGadget.call(this);
} }
RenderJSIframeGadget.ready_list = RenderJSGadget.ready_list.slice(); RenderJSIframeGadget.__ready_list = RenderJSGadget.__ready_list.slice();
RenderJSIframeGadget.ready = RenderJSIframeGadget.ready =
RenderJSGadget.ready; RenderJSGadget.ready;
RenderJSIframeGadget.prototype = new RenderJSGadget(); RenderJSIframeGadget.prototype = new RenderJSGadget();
...@@ -223,8 +224,8 @@ ...@@ -223,8 +224,8 @@
iframe = document.createElement("iframe"); iframe = document.createElement("iframe");
// gadget_instance.element.setAttribute("seamless", "seamless"); // gadget_instance.element.setAttribute("seamless", "seamless");
iframe.setAttribute("src", url); iframe.setAttribute("src", url);
gadget_instance.path = url; gadget_instance.__path = url;
gadget_instance.element = options.element; gadget_instance.__element = options.element;
// Attach it to the DOM // Attach it to the DOM
options.element.appendChild(iframe); options.element.appendChild(iframe);
...@@ -232,47 +233,48 @@ ...@@ -232,47 +233,48 @@
// XXX Manage unbind when deleting the gadget // XXX Manage unbind when deleting the gadget
// Create the communication channel with the iframe // Create the communication channel with the iframe
gadget_instance.chan = Channel.build({ gadget_instance.__chan = Channel.build({
window: iframe.contentWindow, window: iframe.contentWindow,
origin: "*", origin: "*",
scope: "renderJS" scope: "renderJS"
}); });
// Create new method from the declareMethod call inside the iframe // Create new method from the declareMethod call inside the iframe
gadget_instance.chan.bind("declareMethod", function (trans, method_name) { gadget_instance.__chan.bind("declareMethod",
gadget_instance[method_name] = function () { function (trans, method_name) {
var argument_list = arguments; gadget_instance[method_name] = function () {
return new RSVP.Promise(function (resolve, reject) { var argument_list = arguments;
gadget_instance.chan.call({ return new RSVP.Promise(function (resolve, reject) {
method: "methodCall", gadget_instance.__chan.call({
params: [ method: "methodCall",
method_name, params: [
Array.prototype.slice.call(argument_list, 0)], method_name,
success: function (s) { Array.prototype.slice.call(argument_list, 0)],
resolve(s); success: function (s) {
}, resolve(s);
error: function (e) { },
reject(e); error: function (e) {
} reject(e);
}
});
}); });
}); };
}; return "OK";
return "OK"; });
});
// Wait for the iframe to be loaded before continuing // Wait for the iframe to be loaded before continuing
gadget_instance.chan.bind("ready", function (trans) { gadget_instance.__chan.bind("ready", function (trans) {
iframe_loading_deferred.resolve(gadget_instance); iframe_loading_deferred.resolve(gadget_instance);
return "OK"; return "OK";
}); });
gadget_instance.chan.bind("failed", function (trans, params) { gadget_instance.__chan.bind("failed", function (trans, params) {
iframe_loading_deferred.reject(params); iframe_loading_deferred.reject(params);
return "OK"; return "OK";
}); });
gadget_instance.chan.bind("trigger", function (trans, params) { gadget_instance.__chan.bind("trigger", function (trans, params) {
return gadget_instance.trigger(params.event_name, params.options); return gadget_instance.trigger(params.event_name, params.options);
}); });
gadget_instance.chan.bind("acquire", function (trans, params) { gadget_instance.__chan.bind("acquire", function (trans, params) {
gadget_instance.acquire.apply(gadget_instance, params) gadget_instance.acquire.apply(gadget_instance, params)
.then(function (g) { .then(function (g) {
trans.complete(g); trans.complete(g);
...@@ -341,17 +343,17 @@ ...@@ -341,17 +343,17 @@
function ready_wrapper() { function ready_wrapper() {
return gadget_instance; return gadget_instance;
} }
for (i = 0; i < gadget_instance.constructor.ready_list.length; for (i = 0; i < gadget_instance.constructor.__ready_list.length;
i += 1) { i += 1) {
// Put a timeout? // Put a timeout?
queue.push(gadget_instance.constructor.ready_list[i]); queue.push(gadget_instance.constructor.__ready_list[i]);
// Always return the gadget instance after ready function // Always return the gadget instance after ready function
queue.push(ready_wrapper); queue.push(ready_wrapper);
} }
// Store local reference to the gadget instance // Store local reference to the gadget instance
if (options.scope !== undefined) { if (options.scope !== undefined) {
parent_gadget.sub_gadget_dict[options.scope] = gadget_instance; parent_gadget.__sub_gadget_dict[options.scope] = gadget_instance;
} }
return gadget_instance; return gadget_instance;
}) })
...@@ -365,17 +367,17 @@ ...@@ -365,17 +367,17 @@
return loading_gadget_promise; return loading_gadget_promise;
}) })
.declareMethod('getDeclaredGadget', function (gadget_scope) { .declareMethod('getDeclaredGadget', function (gadget_scope) {
if (!this.sub_gadget_dict.hasOwnProperty(gadget_scope)) { if (!this.__sub_gadget_dict.hasOwnProperty(gadget_scope)) {
throw new Error("Gadget scope '" + gadget_scope + "' is not known."); throw new Error("Gadget scope '" + gadget_scope + "' is not known.");
} }
return this.sub_gadget_dict[gadget_scope]; return this.__sub_gadget_dict[gadget_scope];
}) })
.declareMethod('dropGadget', function (gadget_scope) { .declareMethod('dropGadget', function (gadget_scope) {
if (!this.sub_gadget_dict.hasOwnProperty(gadget_scope)) { if (!this.__sub_gadget_dict.hasOwnProperty(gadget_scope)) {
throw new Error("Gadget scope '" + gadget_scope + "' is not known."); throw new Error("Gadget scope '" + gadget_scope + "' is not known.");
} }
// http://perfectionkills.com/understanding-delete/ // http://perfectionkills.com/understanding-delete/
delete this.sub_gadget_dict[gadget_scope]; delete this.__sub_gadget_dict[gadget_scope];
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -483,25 +485,25 @@ ...@@ -483,25 +485,25 @@
tmp_constructor = function () { tmp_constructor = function () {
RenderJSGadget.call(this); RenderJSGadget.call(this);
}; };
tmp_constructor.ready_list = RenderJSGadget.ready_list.slice(); tmp_constructor.__ready_list = RenderJSGadget.__ready_list.slice();
tmp_constructor.declareMethod = tmp_constructor.declareMethod =
RenderJSGadget.declareMethod; RenderJSGadget.declareMethod;
tmp_constructor.ready = tmp_constructor.ready =
RenderJSGadget.ready; RenderJSGadget.ready;
tmp_constructor.prototype = new RenderJSGadget(); tmp_constructor.prototype = new RenderJSGadget();
tmp_constructor.prototype.constructor = tmp_constructor; tmp_constructor.prototype.constructor = tmp_constructor;
tmp_constructor.prototype.path = url; tmp_constructor.prototype.__path = url;
// https://developer.mozilla.org/en-US/docs/HTML_in_XMLHttpRequest // https://developer.mozilla.org/en-US/docs/HTML_in_XMLHttpRequest
// https://developer.mozilla.org/en-US/docs/Web/API/DOMParser // https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
// https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM // https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM
tmp_constructor.template_element = tmp_constructor.__template_element =
(new DOMParser()).parseFromString(xhr.responseText, "text/html"); (new DOMParser()).parseFromString(xhr.responseText, "text/html");
parsed_html = renderJS.parseGadgetHTMLDocument( parsed_html = renderJS.parseGadgetHTMLDocument(
tmp_constructor.template_element tmp_constructor.__template_element
); );
for (key in parsed_html) { for (key in parsed_html) {
if (parsed_html.hasOwnProperty(key)) { if (parsed_html.hasOwnProperty(key)) {
tmp_constructor.prototype[key] = parsed_html[key]; tmp_constructor.prototype['__' + key] = parsed_html[key];
} }
} }
...@@ -608,9 +610,9 @@ ...@@ -608,9 +610,9 @@
// global // global
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
window.rJS = window.renderJS = renderJS; window.rJS = window.renderJS = renderJS;
window.RenderJSGadget = RenderJSGadget; window.__RenderJSGadget = RenderJSGadget;
window.RenderJSEmbeddedGadget = RenderJSEmbeddedGadget; window.__RenderJSEmbeddedGadget = RenderJSEmbeddedGadget;
window.RenderJSIframeGadget = RenderJSIframeGadget; window.__RenderJSIframeGadget = RenderJSIframeGadget;
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
// Bootstrap process. Register the self gadget. // Bootstrap process. Register the self gadget.
...@@ -639,11 +641,11 @@ ...@@ -639,11 +641,11 @@
RenderJSGadget.call(this); RenderJSGadget.call(this);
}; };
tmp_constructor.declareMethod = RenderJSGadget.declareMethod; tmp_constructor.declareMethod = RenderJSGadget.declareMethod;
tmp_constructor.ready_list = RenderJSGadget.ready_list.slice(); tmp_constructor.__ready_list = RenderJSGadget.__ready_list.slice();
tmp_constructor.ready = RenderJSGadget.ready; tmp_constructor.ready = RenderJSGadget.ready;
tmp_constructor.prototype = new RenderJSGadget(); tmp_constructor.prototype = new RenderJSGadget();
tmp_constructor.prototype.constructor = tmp_constructor; tmp_constructor.prototype.constructor = tmp_constructor;
tmp_constructor.prototype.path = url; tmp_constructor.prototype.__path = url;
gadget_model_dict[url] = tmp_constructor; gadget_model_dict[url] = tmp_constructor;
// Create the root gadget instance and put it in the loading stack // Create the root gadget instance and put it in the loading stack
...@@ -767,14 +769,14 @@ ...@@ -767,14 +769,14 @@
key; key;
for (key in settings) { for (key in settings) {
if (settings.hasOwnProperty(key)) { if (settings.hasOwnProperty(key)) {
tmp_constructor.prototype[key] = settings[key]; tmp_constructor.prototype['__' + key] = settings[key];
} }
} }
tmp_constructor.template_element = document.createElement("div"); tmp_constructor.__template_element = document.createElement("div");
root_gadget.element = document.body; root_gadget.__element = document.body;
for (j = 0; j < root_gadget.element.childNodes.length; j += 1) { for (j = 0; j < root_gadget.__element.childNodes.length; j += 1) {
tmp_constructor.template_element.appendChild( tmp_constructor.__template_element.appendChild(
root_gadget.element.childNodes[j].cloneNode(true) root_gadget.__element.childNodes[j].cloneNode(true)
); );
} }
RSVP.all([root_gadget.getRequiredJSList(), RSVP.all([root_gadget.getRequiredJSList(),
...@@ -796,9 +798,9 @@ ...@@ -796,9 +798,9 @@
return root_gadget; return root_gadget;
} }
queue.push(ready_wrapper); queue.push(ready_wrapper);
for (i = 0; i < tmp_constructor.ready_list.length; i += 1) { for (i = 0; i < tmp_constructor.__ready_list.length; i += 1) {
// Put a timeout? // Put a timeout?
queue.push(tmp_constructor.ready_list[i]) queue.push(tmp_constructor.__ready_list[i])
// Always return the gadget instance after ready function // Always return the gadget instance after ready function
.push(ready_wrapper); .push(ready_wrapper);
} }
......
/*jslint nomen: true*/
(function (window, rJS) { (function (window, rJS) {
"use strict"; "use strict";
...@@ -11,8 +12,8 @@ ...@@ -11,8 +12,8 @@
return ready_called; return ready_called;
}) })
.declareMethod('isSubGadgetDictInitialize', function () { .declareMethod('isSubGadgetDictInitialize', function () {
return ((this.hasOwnProperty("sub_gadget_dict")) && return ((this.hasOwnProperty("__sub_gadget_dict")) &&
(JSON.stringify(this.sub_gadget_dict) === "{}")); (JSON.stringify(this.__sub_gadget_dict) === "{}"));
}) })
.declareMethod('triggerError', function (value) { .declareMethod('triggerError', function (value) {
throw new Error("Manually triggered embedded error"); throw new Error("Manually triggered embedded error");
......
/*jslint nomen: true*/
(function (document, renderJS, QUnit, sinon) { (function (document, renderJS, QUnit, sinon) {
"use strict"; "use strict";
var test = QUnit.test, var test = QUnit.test,
...@@ -9,7 +10,10 @@ ...@@ -9,7 +10,10 @@
deepEqual = QUnit.deepEqual, deepEqual = QUnit.deepEqual,
module = QUnit.module, module = QUnit.module,
root_gadget_klass = renderJS(window), root_gadget_klass = renderJS(window),
root_gadget_defer = RSVP.defer(); root_gadget_defer = RSVP.defer(),
RenderJSGadget = __RenderJSGadget,
RenderJSEmbeddedGadget = __RenderJSEmbeddedGadget,
RenderJSIframeGadget = __RenderJSIframeGadget;
// Keep track of the root gadget // Keep track of the root gadget
renderJS(window).ready(function (g) { renderJS(window).ready(function (g) {
...@@ -402,9 +406,9 @@ ...@@ -402,9 +406,9 @@
.then(function (Klass) { .then(function (Klass) {
var instance; var instance;
equal(Klass.prototype.path, url); equal(Klass.prototype.__path, url);
equal(Klass.prototype.foo, 'bar'); equal(Klass.prototype.__foo, 'bar');
equal(Klass.template_element.nodeType, 9); equal(Klass.__template_element.nodeType, 9);
instance = new Klass(); instance = new Klass();
ok(instance instanceof RenderJSGadget); ok(instance instanceof RenderJSGadget);
...@@ -473,7 +477,7 @@ ...@@ -473,7 +477,7 @@
.then(function (Klass) { .then(function (Klass) {
var instance; var instance;
equal(Klass.prototype.path, url); equal(Klass.prototype.__path, url);
instance = new Klass(); instance = new Klass();
ok(instance instanceof RenderJSGadget); ok(instance instanceof RenderJSGadget);
...@@ -931,7 +935,7 @@ ...@@ -931,7 +935,7 @@
test('returns interface_list', function () { test('returns interface_list', function () {
// Check that getInterfaceList return a Promise // Check that getInterfaceList return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.interface_list = "foo"; gadget.__interface_list = "foo";
stop(); stop();
gadget.getInterfaceList() gadget.getInterfaceList()
.then(function (result) { .then(function (result) {
...@@ -966,7 +970,7 @@ ...@@ -966,7 +970,7 @@
test('returns interface_list', function () { test('returns interface_list', function () {
// Check that getRequiredCSSList return a Promise // Check that getRequiredCSSList return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.required_css_list = "foo"; gadget.__required_css_list = "foo";
stop(); stop();
gadget.getRequiredCSSList() gadget.getRequiredCSSList()
.then(function (result) { .then(function (result) {
...@@ -1001,7 +1005,7 @@ ...@@ -1001,7 +1005,7 @@
test('returns interface_list', function () { test('returns interface_list', function () {
// Check that getRequiredJSList return a Promise // Check that getRequiredJSList return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.required_js_list = "foo"; gadget.__required_js_list = "foo";
stop(); stop();
gadget.getRequiredJSList() gadget.getRequiredJSList()
.then(function (result) { .then(function (result) {
...@@ -1036,7 +1040,7 @@ ...@@ -1036,7 +1040,7 @@
test('returns path', function () { test('returns path', function () {
// Check that getPath return a Promise // Check that getPath return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.path = "foo"; gadget.__path = "foo";
stop(); stop();
gadget.getPath() gadget.getPath()
.then(function (result) { .then(function (result) {
...@@ -1071,7 +1075,7 @@ ...@@ -1071,7 +1075,7 @@
test('returns title', function () { test('returns title', function () {
// Check that getTitle return a Promise // Check that getTitle return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.title = "foo"; gadget.__title = "foo";
stop(); stop();
gadget.getTitle() gadget.getTitle()
.then(function (result) { .then(function (result) {
...@@ -1106,7 +1110,7 @@ ...@@ -1106,7 +1110,7 @@
test('returns element property', function () { test('returns element property', function () {
// Check that getElement return a Promise // Check that getElement return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.element = "foo"; gadget.__element = "foo";
stop(); stop();
gadget.getElement() gadget.getElement()
.then(function (result) { .then(function (result) {
...@@ -1461,7 +1465,7 @@ ...@@ -1461,7 +1465,7 @@
}, result; }, result;
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass; Klass.prototype.constructor = Klass;
Klass.ready_list = []; Klass.__ready_list = [];
Klass.ready = RenderJSGadget.ready; Klass.ready = RenderJSGadget.ready;
result = Klass.ready(function () { result = Klass.ready(function () {
...@@ -1481,12 +1485,12 @@ ...@@ -1481,12 +1485,12 @@
callback = function () {return; }; callback = function () {return; };
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass; Klass.prototype.constructor = Klass;
Klass.ready_list = []; Klass.__ready_list = [];
Klass.ready = RenderJSGadget.ready; Klass.ready = RenderJSGadget.ready;
Klass.ready(callback); Klass.ready(callback);
// ready is chainable // ready is chainable
deepEqual(Klass.ready_list, [callback]); deepEqual(Klass.__ready_list, [callback]);
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -1639,7 +1643,7 @@ ...@@ -1639,7 +1643,7 @@
stop(); stop();
gadget.declareGadget(url)//, document.getElementById('qunit-fixture')) gadget.declareGadget(url)//, document.getElementById('qunit-fixture'))
.then(function (new_gadget) { .then(function (new_gadget) {
equal(new_gadget.path, url); equal(new_gadget.__path, url);
ok(new_gadget instanceof RenderJSGadget); ok(new_gadget instanceof RenderJSGadget);
}) })
.always(function () { .always(function () {
...@@ -1664,8 +1668,8 @@ ...@@ -1664,8 +1668,8 @@
stop(); stop();
gadget.declareGadget(url)//, document.getElementById('qunit-fixture')) gadget.declareGadget(url)//, document.getElementById('qunit-fixture'))
.then(function (new_gadget) { .then(function (new_gadget) {
ok(new_gadget.hasOwnProperty("sub_gadget_dict")); ok(new_gadget.hasOwnProperty("__sub_gadget_dict"));
deepEqual(new_gadget.sub_gadget_dict, {}); deepEqual(new_gadget.__sub_gadget_dict, {});
}) })
.always(function () { .always(function () {
start(); start();
...@@ -1734,7 +1738,7 @@ ...@@ -1734,7 +1738,7 @@
.then(function (new_gadget) { .then(function (new_gadget) {
equal(document.getElementById('qunit-fixture').innerHTML, equal(document.getElementById('qunit-fixture').innerHTML,
"<div>youhou2</div><div>bar</div>"); "<div>youhou2</div><div>bar</div>");
equal(new_gadget.element.outerHTML, equal(new_gadget.__element.outerHTML,
"<div><p>Bar content</p></div>"); "<div><p>Bar content</p></div>");
ok(spy_js.calledTwice, "JS count " + spy_js.callCount); ok(spy_js.calledTwice, "JS count " + spy_js.callCount);
equal(spy_js.firstCall.args[0], js1_url, "First JS call"); equal(spy_js.firstCall.args[0], js1_url, "First JS call");
...@@ -2047,7 +2051,7 @@ ...@@ -2047,7 +2051,7 @@
// Subclass RenderJSGadget to not pollute its namespace // Subclass RenderJSGadget to not pollute its namespace
var gadget = new RenderJSGadget(), var gadget = new RenderJSGadget(),
html_url = 'https://example.org/files/qunittest/test98.html'; html_url = 'https://example.org/files/qunittest/test98.html';
gadget.sub_gadget_dict = {}; gadget.__sub_gadget_dict = {};
this.server.respondWith("GET", html_url, [200, { this.server.respondWith("GET", html_url, [200, {
"Content-Type": "text/html" "Content-Type": "text/html"
...@@ -2063,8 +2067,8 @@ ...@@ -2063,8 +2067,8 @@
); );
}) })
.then(function (child_gadget) { .then(function (child_gadget) {
ok(gadget.sub_gadget_dict.hasOwnProperty("foo")); ok(gadget.__sub_gadget_dict.hasOwnProperty("foo"));
equal(gadget.sub_gadget_dict.foo, child_gadget); equal(gadget.__sub_gadget_dict.foo, child_gadget);
}) })
.fail(function (e) { .fail(function (e) {
ok(false, e); ok(false, e);
...@@ -2184,7 +2188,7 @@ ...@@ -2184,7 +2188,7 @@
// Subclass RenderJSGadget to not pollute its namespace // Subclass RenderJSGadget to not pollute its namespace
var gadget = new RenderJSGadget(), var gadget = new RenderJSGadget(),
url = "./embedded.html"; url = "./embedded.html";
gadget.sub_gadget_dict = {}; gadget.__sub_gadget_dict = {};
document.getElementById("qunit-fixture").textContent = ""; document.getElementById("qunit-fixture").textContent = "";
...@@ -2195,8 +2199,8 @@ ...@@ -2195,8 +2199,8 @@
scope: "foo" scope: "foo"
}) })
.then(function (child_gadget) { .then(function (child_gadget) {
ok(gadget.sub_gadget_dict.hasOwnProperty("foo")); ok(gadget.__sub_gadget_dict.hasOwnProperty("foo"));
equal(gadget.sub_gadget_dict.foo, child_gadget); equal(gadget.__sub_gadget_dict.foo, child_gadget);
}) })
.fail(function (e) { .fail(function (e) {
ok(false, e); ok(false, e);
...@@ -2219,13 +2223,13 @@ ...@@ -2219,13 +2223,13 @@
element: document.getElementById('qunit-fixture') element: document.getElementById('qunit-fixture')
}) })
.then(function (new_gadget) { .then(function (new_gadget) {
equal(new_gadget.path, url); equal(new_gadget.__path, url);
ok(new_gadget instanceof RenderJSIframeGadget); ok(new_gadget instanceof RenderJSIframeGadget);
equal( equal(
new_gadget.element.innerHTML, new_gadget.__element.innerHTML,
'<iframe src="' + url + '"></iframe>' '<iframe src="' + url + '"></iframe>'
); );
ok(new_gadget.chan !== undefined); ok(new_gadget.__chan !== undefined);
}) })
.always(function () { .always(function () {
start(); start();
...@@ -2245,8 +2249,8 @@ ...@@ -2245,8 +2249,8 @@
element: document.getElementById('qunit-fixture') element: document.getElementById('qunit-fixture')
}) })
.then(function (new_gadget) { .then(function (new_gadget) {
ok(new_gadget.hasOwnProperty("sub_gadget_dict")); ok(new_gadget.hasOwnProperty("__sub_gadget_dict"));
deepEqual(new_gadget.sub_gadget_dict, {}); deepEqual(new_gadget.__sub_gadget_dict, {});
}) })
.always(function () { .always(function () {
start(); start();
...@@ -2413,7 +2417,7 @@ ...@@ -2413,7 +2417,7 @@
test('returns value from sub_gadget_dict attribute', function () { test('returns value from sub_gadget_dict attribute', function () {
// Check that getDeclaredGadget return a Promise // Check that getDeclaredGadget return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.sub_gadget_dict = {foo: "bar"}; gadget.__sub_gadget_dict = {foo: "bar"};
stop(); stop();
gadget.getDeclaredGadget("foo") gadget.getDeclaredGadget("foo")
.then(function (result) { .then(function (result) {
...@@ -2427,7 +2431,7 @@ ...@@ -2427,7 +2431,7 @@
test('throw an error if scope is unknown', function () { test('throw an error if scope is unknown', function () {
// Check that getDeclaredGadget return a Promise // Check that getDeclaredGadget return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.sub_gadget_dict = {}; gadget.__sub_gadget_dict = {};
stop(); stop();
gadget.getDeclaredGadget("foo") gadget.getDeclaredGadget("foo")
.then(function () { .then(function () {
...@@ -2453,12 +2457,12 @@ ...@@ -2453,12 +2457,12 @@
test('returns value from sub_gadget_dict attribute', function () { test('returns value from sub_gadget_dict attribute', function () {
// Check that dropGadget return a Promise // Check that dropGadget return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.sub_gadget_dict = {foo: "bar"}; gadget.__sub_gadget_dict = {foo: "bar"};
stop(); stop();
gadget.dropGadget("foo") gadget.dropGadget("foo")
.then(function (result) { .then(function (result) {
equal(result, undefined); equal(result, undefined);
equal(JSON.stringify(gadget.sub_gadget_dict), "{}"); equal(JSON.stringify(gadget.__sub_gadget_dict), "{}");
}) })
.always(function () { .always(function () {
start(); start();
...@@ -2468,7 +2472,7 @@ ...@@ -2468,7 +2472,7 @@
test('throw an error if scope is unknown', function () { test('throw an error if scope is unknown', function () {
// Check that dropGadget return a Promise // Check that dropGadget return a Promise
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
gadget.sub_gadget_dict = {}; gadget.__sub_gadget_dict = {};
stop(); stop();
gadget.dropGadget("foo") gadget.dropGadget("foo")
.then(function () { .then(function () {
...@@ -2499,33 +2503,33 @@ ...@@ -2499,33 +2503,33 @@
root_gadget_defer.promise root_gadget_defer.promise
.then(function (root_gadget) { .then(function (root_gadget) {
// Check instance // Check instance
equal(root_gadget.path, window.location.href); equal(root_gadget.__path, window.location.href);
equal(root_gadget.title, document.title); equal(root_gadget.__title, document.title);
deepEqual(root_gadget.interface_list, []); deepEqual(root_gadget.__interface_list, []);
deepEqual(root_gadget.required_css_list, deepEqual(root_gadget.__required_css_list,
["../node_modules/grunt-contrib-qunit/test/libs/qunit.css"]); ["../node_modules/grunt-contrib-qunit/test/libs/qunit.css"]);
deepEqual(root_gadget.required_js_list, [ deepEqual(root_gadget.__required_js_list, [
"../node_modules/rsvp/dist/rsvp-2.0.4.js", "../node_modules/rsvp/dist/rsvp-2.0.4.js",
"../node_modules/grunt-contrib-qunit/test/libs/qunit.js", "../node_modules/grunt-contrib-qunit/test/libs/qunit.js",
"../node_modules/sinon/pkg/sinon.js", "../node_modules/sinon/pkg/sinon.js",
"../dist/renderjs-latest.js", "../dist/renderjs-latest.js",
"renderjs_test.js" "renderjs_test.js"
]); ]);
equal(root_gadget.element.outerHTML, document.body.outerHTML); equal(root_gadget.__element.outerHTML, document.body.outerHTML);
// Check klass // Check klass
equal(root_gadget.constructor.prototype.path, window.location.href); equal(root_gadget.constructor.prototype.__path, window.location.href);
equal(root_gadget.constructor.prototype.title, document.title); equal(root_gadget.constructor.prototype.__title, document.title);
deepEqual(root_gadget.constructor.prototype.interface_list, []); deepEqual(root_gadget.constructor.prototype.__interface_list, []);
deepEqual(root_gadget.constructor.prototype.required_css_list, deepEqual(root_gadget.constructor.prototype.__required_css_list,
["../node_modules/grunt-contrib-qunit/test/libs/qunit.css"]); ["../node_modules/grunt-contrib-qunit/test/libs/qunit.css"]);
deepEqual(root_gadget.constructor.prototype.required_js_list, [ deepEqual(root_gadget.constructor.prototype.__required_js_list, [
"../node_modules/rsvp/dist/rsvp-2.0.4.js", "../node_modules/rsvp/dist/rsvp-2.0.4.js",
"../node_modules/grunt-contrib-qunit/test/libs/qunit.js", "../node_modules/grunt-contrib-qunit/test/libs/qunit.js",
"../node_modules/sinon/pkg/sinon.js", "../node_modules/sinon/pkg/sinon.js",
"../dist/renderjs-latest.js", "../dist/renderjs-latest.js",
"renderjs_test.js" "renderjs_test.js"
]); ]);
var html = root_gadget.constructor.template_element.outerHTML; var html = root_gadget.constructor.__template_element.outerHTML;
ok(/^<div>\s*<h1 id="qunit-header">/.test(html), html); ok(/^<div>\s*<h1 id="qunit-header">/.test(html), html);
ok(root_gadget.on !== undefined); ok(root_gadget.on !== undefined);
ok(root_gadget.off !== undefined); ok(root_gadget.off !== undefined);
...@@ -2533,8 +2537,8 @@ ...@@ -2533,8 +2537,8 @@
ok(root_gadget instanceof RenderJSGadget); ok(root_gadget instanceof RenderJSGadget);
ok(root_gadget_klass, root_gadget.constructor); ok(root_gadget_klass, root_gadget.constructor);
ok(root_gadget.aq_parent !== undefined); ok(root_gadget.aq_parent !== undefined);
ok(root_gadget.hasOwnProperty("sub_gadget_dict")); ok(root_gadget.hasOwnProperty("__sub_gadget_dict"));
deepEqual(root_gadget.sub_gadget_dict, {}); deepEqual(root_gadget.__sub_gadget_dict, {});
}) })
.fail(function (e) { .fail(function (e) {
ok(false, e); ok(false, e);
......
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