Create monorepo from known-good production state
This commit is contained in:
commit
c034824338
651 changed files with 120469 additions and 0 deletions
37
svgnest/util/domparser.js
Normal file
37
svgnest/util/domparser.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* inspired by https://gist.github.com/1129031 */
|
||||
/*global document, DOMParser*/
|
||||
|
||||
(function(DOMParser) {
|
||||
"use strict";
|
||||
|
||||
var
|
||||
proto = DOMParser.prototype
|
||||
, nativeParse = proto.parseFromString
|
||||
;
|
||||
|
||||
// Firefox/Opera/IE throw errors on unsupported types
|
||||
try {
|
||||
// WebKit returns null on unsupported types
|
||||
if ((new DOMParser()).parseFromString("", "text/html")) {
|
||||
// text/html parsing is natively supported
|
||||
return;
|
||||
}
|
||||
} catch (ex) {}
|
||||
|
||||
proto.parseFromString = function(markup, type) {
|
||||
if (/^\s*text\/html\s*(?:;|$)/i.test(type)) {
|
||||
var
|
||||
doc = document.implementation.createHTMLDocument("")
|
||||
;
|
||||
if (markup.toLowerCase().indexOf('<!doctype') > -1) {
|
||||
doc.documentElement.innerHTML = markup;
|
||||
}
|
||||
else {
|
||||
doc.body.innerHTML = markup;
|
||||
}
|
||||
return doc;
|
||||
} else {
|
||||
return nativeParse.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}(DOMParser));
|
||||
Loading…
Add table
Add a link
Reference in a new issue