@@ -10,6 +10,7 @@ function echo () {
10
10
// + improved by: Brett Zamir (http://brett-zamir.me)
11
11
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
12
12
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
13
+ // + bugfixed by: EdorFaus
13
14
// % note 1: If browsers start to support DOM Level 3 Load and Save (parsing/serializing),
14
15
// % note 1: we wouldn't need any such long code (even most of the code below). See
15
16
// % note 1: link below for a cross-browser implementation in JavaScript. HTML5 might
@@ -22,20 +23,18 @@ function echo () {
22
23
// * example 1: echo('<div><p>abc</p><p>abc</p></div>');
23
24
// * returns 1: undefined
24
25
25
- var arg = '' , argc = arguments . length , argv = arguments , i = 0 ;
26
- var win = this . window ;
27
- var d = win . document ;
28
- var ns_xhtml = 'http://www.w3.org/1999/xhtml' ;
29
- var ns_xul = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' ; // If we're in a XUL context
30
-
31
- var holder ;
26
+ var arg = '' , argc = arguments . length , argv = arguments , i = 0 , holder ,
27
+ win = this . window ,
28
+ d = win . document ,
29
+ ns_xhtml = 'http://www.w3.org/1999/xhtml' ,
30
+ ns_xul = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' ; // If we're in a XUL context
32
31
33
32
var stringToDOM = function ( str , parent , ns , container ) {
34
33
var extraNSs = '' ;
35
34
if ( ns === ns_xul ) {
36
- extraNSs = ' xmlns:html="' + ns_xhtml + '"' ;
35
+ extraNSs = ' xmlns:html="' + ns_xhtml + '"' ;
37
36
}
38
- var stringContainer = '<' + container + ' xmlns="' + ns + '"' + extraNSs + '>' + str + '</' + container + '>' ;
37
+ var stringContainer = '<' + container + ' xmlns="' + ns + '"' + extraNSs + '>' + str + '</' + container + '>' ;
39
38
if ( win . DOMImplementationLS &&
40
39
win . DOMImplementationLS . createLSInput &&
41
40
win . DOMImplementationLS . createLSParser ) { // Follows the DOM 3 Load and Save standard, but not
@@ -52,8 +51,8 @@ function echo () {
52
51
// If we're in XHTML, we'll try to allow the XHTML namespace to be available by default
53
52
try {
54
53
var fc = new DOMParser ( ) . parseFromString ( stringContainer , 'text/xml' ) ;
55
- if ( ! fc || ! fc . documentElement ||
56
- fc . documentElement . localName !== 'parsererror' ||
54
+ if ( fc && fc . documentElement &&
55
+ fc . documentElement . localName !== 'parsererror' &&
57
56
fc . documentElement . namespaceURI !== 'http://www.mozilla.org/newlayout/xml/parsererror.xml' ) {
58
57
return fc . documentElement . firstChild ;
59
58
}
0 commit comments