Commit 341fdcf0 authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'upstream/master' into zope4py2

parents 7518e634 dad8e60c
/*globals window, document, RSVP, rJS, XMLHttpRequest, DOMParser, URL, /*globals window, document, RSVP, rJS, XMLHttpRequest, URL,
history, console */ history, console */
/*jslint indent: 2, maxlen: 80*/ /*jslint indent: 2, maxlen: 80*/
(function (window, document, RSVP, rJS, XMLHttpRequest, DOMParser, URL, (function (window, document, RSVP, rJS, XMLHttpRequest, URL,
loopEventListener, history, console) { loopEventListener, history, console) {
"use strict"; "use strict";
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
style_gadget: gadget.getDeclaredGadget('renderer') style_gadget: gadget.getDeclaredGadget('renderer')
})) }))
.push(function (result_dict) { .push(function (result_dict) {
var dom_parser = (new DOMParser()).parseFromString( var dom_parser = rJS.parseDocumentStringOrFail(
result_dict.xhr.responseText, result_dict.xhr.responseText,
'text/html' 'text/html'
), ),
...@@ -472,5 +472,5 @@ ...@@ -472,5 +472,5 @@
// with browsers without javascript // with browsers without javascript
hidePage(); hidePage();
}(window, document, RSVP, rJS, XMLHttpRequest, DOMParser, URL, }(window, document, RSVP, rJS, XMLHttpRequest, URL,
rJS.loopEventListener, history, console)); rJS.loopEventListener, history, console));
\ No newline at end of file
...@@ -781,6 +781,32 @@ if (typeof document.contains !== 'function') { ...@@ -781,6 +781,32 @@ if (typeof document.contains !== 'function') {
ScopeError.prototype = new Error(); ScopeError.prototype = new Error();
ScopeError.prototype.constructor = ScopeError; ScopeError.prototype.constructor = ScopeError;
//////////////////////////////////////////
// ParserError
//////////////////////////////////////////
function DOMParserError(message) {
this.name = "DOMParserError";
if ((message !== undefined) && (typeof message !== "string")) {
throw new TypeError('You must pass a string for DOMParserError.');
}
this.message = message || "Default Message";
}
DOMParserError.prototype = new Error();
DOMParserError.prototype.constructor = DOMParserError;
//////////////////////////////////////////
// DOMParser
//////////////////////////////////////////
function parseDocumentStringOrFail(string, mime_type) {
var doc = new DOMParser().parseFromString(string, mime_type),
error_node = doc.querySelector('parsererror');
if (error_node !== null) {
// parsing failed
throw new DOMParserError(error_node.textContent);
}
return doc;
}
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// renderJS.IframeSerializationError // renderJS.IframeSerializationError
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -1901,8 +1927,7 @@ if (typeof document.contains !== 'function') { ...@@ -1901,8 +1927,7 @@ if (typeof document.contains !== 'function') {
.push(function handleDataURLAjaxResponse(xhr) { .push(function handleDataURLAjaxResponse(xhr) {
// Insert a "base" element, in order to resolve all relative links // Insert a "base" element, in order to resolve all relative links
// which could get broken with a data url // which could get broken with a data url
var doc = (new DOMParser()).parseFromString(xhr.responseText, var doc = parseDocumentStringOrFail(xhr.responseText, 'text/html'),
'text/html'),
base = doc.createElement('base'), base = doc.createElement('base'),
blob; blob;
base.href = url; base.href = url;
...@@ -2200,7 +2225,7 @@ if (typeof document.contains !== 'function') { ...@@ -2200,7 +2225,7 @@ if (typeof document.contains !== 'function') {
// 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"); parseDocumentStringOrFail(xhr.responseText, "text/html");
parsed_html = renderJS.parseGadgetHTMLDocument( parsed_html = renderJS.parseGadgetHTMLDocument(
tmp_constructor.__template_element, tmp_constructor.__template_element,
url, url,
...@@ -2406,6 +2431,8 @@ if (typeof document.contains !== 'function') { ...@@ -2406,6 +2431,8 @@ if (typeof document.contains !== 'function') {
renderJS.ScopeError = ScopeError; renderJS.ScopeError = ScopeError;
renderJS.IframeSerializationError = IframeSerializationError; renderJS.IframeSerializationError = IframeSerializationError;
renderJS.loopEventListener = loopEventListener; renderJS.loopEventListener = loopEventListener;
renderJS.DOMParserError = DOMParserError;
renderJS.parseDocumentStringOrFail = parseDocumentStringOrFail;
window.rJS = window.renderJS = renderJS; window.rJS = window.renderJS = renderJS;
window.__RenderJSGadget = RenderJSGadget; window.__RenderJSGadget = RenderJSGadget;
window.__RenderJSEmbeddedGadget = RenderJSEmbeddedGadget; window.__RenderJSEmbeddedGadget = RenderJSEmbeddedGadget;
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>996.23761.26725.45789</string> </value> <value> <string>998.17699.36537.24439</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1641216662.48</float> <float>1668780748.06</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -781,6 +781,32 @@ if (typeof document.contains !== 'function') { ...@@ -781,6 +781,32 @@ if (typeof document.contains !== 'function') {
ScopeError.prototype = new Error(); ScopeError.prototype = new Error();
ScopeError.prototype.constructor = ScopeError; ScopeError.prototype.constructor = ScopeError;
//////////////////////////////////////////
// ParserError
//////////////////////////////////////////
function DOMParserError(message) {
this.name = "DOMParserError";
if ((message !== undefined) && (typeof message !== "string")) {
throw new TypeError('You must pass a string for DOMParserError.');
}
this.message = message || "Default Message";
}
DOMParserError.prototype = new Error();
DOMParserError.prototype.constructor = DOMParserError;
//////////////////////////////////////////
// DOMParser
//////////////////////////////////////////
function parseDocumentStringOrFail(string, mime_type) {
var doc = new DOMParser().parseFromString(string, mime_type),
error_node = doc.querySelector('parsererror');
if (error_node !== null) {
// parsing failed
throw new DOMParserError(error_node.textContent);
}
return doc;
}
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// renderJS.IframeSerializationError // renderJS.IframeSerializationError
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -1901,8 +1927,7 @@ if (typeof document.contains !== 'function') { ...@@ -1901,8 +1927,7 @@ if (typeof document.contains !== 'function') {
.push(function handleDataURLAjaxResponse(xhr) { .push(function handleDataURLAjaxResponse(xhr) {
// Insert a "base" element, in order to resolve all relative links // Insert a "base" element, in order to resolve all relative links
// which could get broken with a data url // which could get broken with a data url
var doc = (new DOMParser()).parseFromString(xhr.responseText, var doc = parseDocumentStringOrFail(xhr.responseText, 'text/html'),
'text/html'),
base = doc.createElement('base'), base = doc.createElement('base'),
blob; blob;
base.href = url; base.href = url;
...@@ -2200,7 +2225,7 @@ if (typeof document.contains !== 'function') { ...@@ -2200,7 +2225,7 @@ if (typeof document.contains !== 'function') {
// 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"); parseDocumentStringOrFail(xhr.responseText, "text/html");
parsed_html = renderJS.parseGadgetHTMLDocument( parsed_html = renderJS.parseGadgetHTMLDocument(
tmp_constructor.__template_element, tmp_constructor.__template_element,
url, url,
...@@ -2406,6 +2431,8 @@ if (typeof document.contains !== 'function') { ...@@ -2406,6 +2431,8 @@ if (typeof document.contains !== 'function') {
renderJS.ScopeError = ScopeError; renderJS.ScopeError = ScopeError;
renderJS.IframeSerializationError = IframeSerializationError; renderJS.IframeSerializationError = IframeSerializationError;
renderJS.loopEventListener = loopEventListener; renderJS.loopEventListener = loopEventListener;
renderJS.DOMParserError = DOMParserError;
renderJS.parseDocumentStringOrFail = parseDocumentStringOrFail;
window.rJS = window.renderJS = renderJS; window.rJS = window.renderJS = renderJS;
window.__RenderJSGadget = RenderJSGadget; window.__RenderJSGadget = RenderJSGadget;
window.__RenderJSEmbeddedGadget = RenderJSEmbeddedGadget; window.__RenderJSEmbeddedGadget = RenderJSEmbeddedGadget;
......
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