Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
b05c05f4
Commit
b05c05f4
authored
Nov 18, 2022
by
Romain Courteaud
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail if DOMParser report HTML issue.
parent
846e9ef2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
renderjs.js
renderjs.js
+30
-3
No files found.
renderjs.js
View file @
b05c05f4
...
...
@@ -61,6 +61,32 @@
ScopeError
.
prototype
=
new
Error
();
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
/////////////////////////////////////////////////////////////////
...
...
@@ -1181,8 +1207,7 @@
.
push
(
function
handleDataURLAjaxResponse
(
xhr
)
{
// Insert a "base" element, in order to resolve all relative links
// which could get broken with a data url
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
),
var
doc
=
parseDocumentStringOrFail
(
xhr
.
responseText
,
'
text/html
'
),
base
=
doc
.
createElement
(
'
base
'
),
blob
;
base
.
href
=
url
;
...
...
@@ -1480,7 +1505,7 @@
// https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
// https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM
tmp_constructor
.
__template_element
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
"
text/html
"
);
parseDocumentStringOrFail
(
xhr
.
responseText
,
"
text/html
"
);
parsed_html
=
renderJS
.
parseGadgetHTMLDocument
(
tmp_constructor
.
__template_element
,
url
,
...
...
@@ -1686,6 +1711,8 @@
renderJS
.
ScopeError
=
ScopeError
;
renderJS
.
IframeSerializationError
=
IframeSerializationError
;
renderJS
.
loopEventListener
=
loopEventListener
;
renderJS
.
DOMParserError
=
DOMParserError
;
renderJS
.
parseDocumentStringOrFail
=
parseDocumentStringOrFail
;
window
.
rJS
=
window
.
renderJS
=
renderJS
;
window
.
__RenderJSGadget
=
RenderJSGadget
;
window
.
__RenderJSEmbeddedGadget
=
RenderJSEmbeddedGadget
;
...
...
Romain Courteaud
@romain
mentioned in merge request
erp5!1977 (merged)
·
Jul 31, 2024
mentioned in merge request
erp5!1977 (merged)
mentioned in merge request erp5!1977
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment