Comparing version 3.3.0 to 3.3.1
@@ -0,1 +1,7 @@ | ||
#### 3.3.1 (2019-07-15) | ||
##### Bug Fixes | ||
* **parseXml:** [#74](https://github.com/Axinom/x2js/pull/74) Fix old IE compatibility check ([a96daa14](https://github.com/Axinom/x2js/commit/a96daa1480c63604c0d9e1882c4b890f9ba0f0f7)) | ||
#### 3.2.6 (2019-01-24) | ||
@@ -2,0 +8,0 @@ #### 3.2.5 (2019-01-23) |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e(require("xmldom").DOMParser):t.X2JS=e()}(this,function(y){"use strict";return function(p){(p=p||{}).arrayAccessForm=p.arrayAccessForm||"none",p.emptyNodeForm=p.emptyNodeForm||"text",p.jsAttributeFilter=p.jsAttributeFilter,p.jsAttributeConverter=p.jsAttributeConverter,p.attributeConverters=p.attributeConverters||[],p.datetimeAccessFormPaths=p.datetimeAccessFormPaths||[],p.arrayAccessFormPaths=p.arrayAccessFormPaths||[],p.xmldomOptions=p.xmldomOptions||{},void 0===p.enableToStringFunc&&(p.enableToStringFunc=!0),void 0===p.skipEmptyTextNodesForObj&&(p.skipEmptyTextNodesForObj=!0),void 0===p.stripWhitespaces&&(p.stripWhitespaces=!0),void 0===p.useDoubleQuotes&&(p.useDoubleQuotes=!0),void 0===p.ignoreRoot&&(p.ignoreRoot=!1),void 0===p.escapeMode&&(p.escapeMode=!0),void 0===p.attributePrefix&&(p.attributePrefix="_"),void 0===p.selfClosingElements&&(p.selfClosingElements=!0),void 0===p.keepCData&&(p.keepCData=!1),void 0===p.jsDateUTC&&(p.jsDateUTC=!1),function(){function t(t){var e=String(t);return 1===e.length&&(e="0"+e),e}"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|^\n+|(\s|\n)+$/g,"")}),"function"!=typeof Date.prototype.toISOString&&(Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+t(this.getUTCMonth()+1)+"-"+t(this.getUTCDate())+"T"+t(this.getUTCHours())+":"+t(this.getUTCMinutes())+":"+t(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"})}();var d={ELEMENT_NODE:1,TEXT_NODE:3,CDATA_SECTION_NODE:4,COMMENT_NODE:8,DOCUMENT_NODE:9};function g(t){var e=t.localName;return null==e&&(e=t.baseName),null!=e&&""!==e||(e=t.nodeName),e}function c(t){return"string"==typeof t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):t}function m(t,e,r){switch(p.arrayAccessForm){case"property":t[e]instanceof Array?t[e+"_asArray"]=t[e]:t[e+"_asArray"]=[t[e]]}if(!(t[e]instanceof Array)&&0<p.arrayAccessFormPaths.length){for(var n=!1,i=0;i<p.arrayAccessFormPaths.length;i++){var o=p.arrayAccessFormPaths[i];if("string"==typeof o){if(o===r){n=!0;break}}else if(o instanceof RegExp){if(o.test(r)){n=!0;break}}else if("function"==typeof o&&o(e,r)){n=!0;break}}n&&(t[e]=[t[e]])}}function x(t){var e=t.split(/[-T:+Z]/g),r=new Date(e[0],e[1]-1,e[2]),n=e[5].split(".");if(r.setHours(e[3],e[4],n[0]),1<n.length&&r.setMilliseconds(n[1]),e[6]&&e[7]){var i=60*e[6]+Number(e[7]);i=0+("-"===(/\d\d-\d\d:\d\d$/.test(t)?"-":"+")?-1*i:i),r.setMinutes(r.getMinutes()-i-r.getTimezoneOffset())}else-1!==t.indexOf("Z",t.length-1)&&(r=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds())));return r}function r(t,e){for(var r={__cnt:0},n=t.childNodes,i=0;i<n.length;i++){var o=n.item(i),a=g(o);o.nodeType!==d.COMMENT_NODE&&(r.__cnt++,null==r[a]?(r[a]=h(o,e+"."+a),m(r,a,e+"."+a)):(r[a]instanceof Array||(r[a]=[r[a]],m(r,a,e+"."+a)),r[a][r[a].length]=h(o,e+"."+a)))}for(var s=0;s<t.attributes.length;s++){var c=t.attributes.item(s);r.__cnt++;for(var l=c.value,u=0;u<p.attributeConverters.length;u++){var f=p.attributeConverters[u];f.test.call(null,c.name,c.value)&&(l=f.convert.call(null,c.name,c.value))}r[p.attributePrefix+c.name]=l}var _=t.prefix;return _&&(r.__cnt++,r.__prefix=_),r["#text"]&&(r.__text=r["#text"],r.__text instanceof Array&&(r.__text=r.__text.join("\n")),p.escapeMode&&(r.__text=r.__text.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")),p.stripWhitespaces&&(r.__text=r.__text.trim()),delete r["#text"],"property"===p.arrayAccessForm&&delete r["#text_asArray"],r.__text=function(t,e,r){if(0<p.datetimeAccessFormPaths.length)for(var n=r.split(".#")[0],i=0;i<p.datetimeAccessFormPaths.length;i++){var o=p.datetimeAccessFormPaths[i];if("string"==typeof o){if(o===n)return x(t)}else if(o instanceof RegExp){if(o.test(n))return x(t)}else if("function"==typeof o&&o(n))return x(t)}return t}(r.__text,0,e+".#text")),r.hasOwnProperty("#cdata-section")&&(r.__cdata=r["#cdata-section"],delete r["#cdata-section"],"property"===p.arrayAccessForm&&delete r["#cdata-section_asArray"]),1===r.__cnt&&r.__text?r=r.__text:0===r.__cnt&&"text"===p.emptyNodeForm?r="":1<r.__cnt&&void 0!==r.__text&&p.skipEmptyTextNodesForObj&&(p.stripWhitespaces&&""===r.__text||""===r.__text.trim())&&delete r.__text,delete r.__cnt,p.keepCData||r.hasOwnProperty("__text")||!r.hasOwnProperty("__cdata")||1!==Object.keys(r).length?(p.enableToStringFunc&&(r.__text||r.__cdata)&&(r.toString=function(){return(this.__text?this.__text:"")+(this.__cdata?this.__cdata:"")}),r):r.__cdata?r.__cdata:""}function h(t,e){return t.nodeType===d.DOCUMENT_NODE?function(t){for(var e={},r=t.childNodes,n=0;n<r.length;n++){var i=r.item(n);if(i.nodeType===d.ELEMENT_NODE){var o=g(i);p.ignoreRoot?e=h(i,o):e[o]=h(i,o)}}return e}(t):t.nodeType===d.ELEMENT_NODE?r(t,e):t.nodeType===d.TEXT_NODE||t.nodeType===d.CDATA_SECTION_NODE?t.nodeValue:null}function o(t,e,r,n){var i="<"+(t&&t.__prefix?t.__prefix+":":"")+e;if(r)for(var o=0;o<r.length;o++){var a=r[o],s=t[a];p.escapeMode&&(s=c(s)),i+=" "+a.substr(p.attributePrefix.length)+"=",p.useDoubleQuotes?i+='"'+s+'"':i+="'"+s+"'"}return i+=n?" />":">"}function i(t,e){return"</"+(t&&t.__prefix?t.__prefix+":":"")+e+">"}function a(t,e){return"property"===p.arrayAccessForm&&(r=e.toString(),n="_asArray",-1!==r.indexOf(n,r.length-n.length))||0===e.toString().indexOf(p.attributePrefix)||0===e.toString().indexOf("__")||t[e]instanceof Function;var r,n}function s(t){var e=0;if(t instanceof Object)for(var r in t)a(t,r)||e++;return e}function l(t){var e=[];if(t instanceof Object)for(var r in t)-1===r.toString().indexOf("__")&&0===r.toString().indexOf(p.attributePrefix)&&e.push(r);return e}function u(t){var e,r,n="";return t instanceof Object?n+=(r="",(e=t).__cdata&&(r+="<![CDATA["+e.__cdata+"]]>"),(e.__text||"number"==typeof e.__text||"boolean"==typeof e.__text)&&(p.escapeMode?r+=c(e.__text):r+=e.__text),r):null!==t&&(p.escapeMode?n+=c(t):n+=t),n}function f(t,e,r){var n="";if(p.jsAttributeFilter&&p.jsAttributeFilter.call(null,e,t))return n;if(p.jsAttributeConverter&&(t=p.jsAttributeConverter.call(null,e,t)),null!=t&&""!==t||!p.selfClosingElements)if("object"==typeof t)if("[object Array]"===Object.prototype.toString.call(t))n+=function(t,e,r){var n="";if(0===t.length)n+=o(t,e,r,!0);else for(var i=0;i<t.length;i++)n+=f(t[i],e,l(t[i]));return n}(t,e,r);else if(t instanceof Date)n+=o(t,e,r,!1),n+=p.jsDateUTC?t.toUTCString():t.toISOString(),n+=i(t,e);else{0<s(t)||"number"==typeof t.__text||"boolean"==typeof t.__text||t.__text||t.__cdata?(n+=o(t,e,r,!1),n+=_(t),n+=i(t,e)):p.selfClosingElements?n+=o(t,e,r,!0):(n+=o(t,e,r,!1),n+=i(t,e))}else n+=o(t,e,r,!1),n+=u(t),n+=i(t,e);else n+=o(t,e,r,!0);return n}function _(t){var e="";if(0<s(t))for(var r in t)if(!a(t,r)){var n=t[r];e+=f(n,r,l(n))}return e+=u(t)}function n(t){if(void 0===t)return null;if("string"!=typeof t)return null;var e=null,r=null;if(y)r=(e=new y(p.xmldomOptions)).parseFromString(t,"text/xml");else if(window&&window.DOMParser){e=new window.DOMParser;var n=null;if(!(window.ActiveXObject||"ActiveXObject"in window))try{n=e.parseFromString("INVALID","text/xml").childNodes[0].namespaceURI}catch(t){n=null}try{r=e.parseFromString(t,"text/xml"),null!==n&&0<r.getElementsByTagNameNS(n,"parsererror").length&&(r=null)}catch(t){r=null}}else 0===t.indexOf("<?")&&(t=t.substr(t.indexOf("?>")+2)),(r=new ActiveXObject("Microsoft.XMLDOM")).async="false",r.loadXML(t);return r}this.asArray=function(t){return null==t?[]:t instanceof Array?t:[t]},this.toXmlDateTime=function(t){return t instanceof Date?t.toISOString():"number"==typeof t?new Date(t).toISOString():null},this.asDateTime=function(t){return"string"==typeof t?x(t):t},this.xml2dom=function(t){return n(t)},this.dom2js=function(t){return h(t,null)},this.js2dom=function(t){return n(this.js2xml(t))},this.xml2js=function(t){var e=n(t);return null!=e?this.dom2js(e):null},this.js2xml=function(t){return _(t)},this.getVersion=function(){return"3.1.1"}}}); | ||
!function(t,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e(require("xmldom").DOMParser):t.X2JS=e()}(this,function(y){"use strict";return function(d){(d=d||{}).arrayAccessForm=d.arrayAccessForm||"none",d.emptyNodeForm=d.emptyNodeForm||"text",d.jsAttributeFilter=d.jsAttributeFilter,d.jsAttributeConverter=d.jsAttributeConverter,d.attributeConverters=d.attributeConverters||[],d.datetimeAccessFormPaths=d.datetimeAccessFormPaths||[],d.arrayAccessFormPaths=d.arrayAccessFormPaths||[],d.xmldomOptions=d.xmldomOptions||{},void 0===d.enableToStringFunc&&(d.enableToStringFunc=!0),void 0===d.skipEmptyTextNodesForObj&&(d.skipEmptyTextNodesForObj=!0),void 0===d.stripWhitespaces&&(d.stripWhitespaces=!0),void 0===d.useDoubleQuotes&&(d.useDoubleQuotes=!0),void 0===d.ignoreRoot&&(d.ignoreRoot=!1),void 0===d.escapeMode&&(d.escapeMode=!0),void 0===d.attributePrefix&&(d.attributePrefix="_"),void 0===d.selfClosingElements&&(d.selfClosingElements=!0),void 0===d.keepCData&&(d.keepCData=!1),void 0===d.jsDateUTC&&(d.jsDateUTC=!1),function(){function t(t){var e=String(t);return 1===e.length&&(e="0"+e),e}"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|^\n+|(\s|\n)+$/g,"")}),"function"!=typeof Date.prototype.toISOString&&(Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+t(this.getUTCMonth()+1)+"-"+t(this.getUTCDate())+"T"+t(this.getUTCHours())+":"+t(this.getUTCMinutes())+":"+t(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"})}();var p={ELEMENT_NODE:1,TEXT_NODE:3,CDATA_SECTION_NODE:4,COMMENT_NODE:8,DOCUMENT_NODE:9};function g(t){var e=t.localName;return null==e&&(e=t.baseName),null!=e&&""!==e||(e=t.nodeName),e}function c(t){return"string"==typeof t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):t}function m(t,e,r){switch(d.arrayAccessForm){case"property":t[e]instanceof Array?t[e+"_asArray"]=t[e]:t[e+"_asArray"]=[t[e]]}if(!(t[e]instanceof Array)&&0<d.arrayAccessFormPaths.length){for(var n=!1,i=0;i<d.arrayAccessFormPaths.length;i++){var o=d.arrayAccessFormPaths[i];if("string"==typeof o){if(o===r){n=!0;break}}else if(o instanceof RegExp){if(o.test(r)){n=!0;break}}else if("function"==typeof o&&o(e,r)){n=!0;break}}n&&(t[e]=[t[e]])}}function x(t){var e=t.split(/[-T:+Z]/g),r=new Date(e[0],e[1]-1,e[2]),n=e[5].split(".");if(r.setHours(e[3],e[4],n[0]),1<n.length&&r.setMilliseconds(n[1]),e[6]&&e[7]){var i=60*e[6]+Number(e[7]);i=0+("-"===(/\d\d-\d\d:\d\d$/.test(t)?"-":"+")?-1*i:i),r.setMinutes(r.getMinutes()-i-r.getTimezoneOffset())}else-1!==t.indexOf("Z",t.length-1)&&(r=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds())));return r}function r(t,e){for(var r={__cnt:0},n=t.childNodes,i=0;i<n.length;i++){var o=n.item(i),a=g(o);o.nodeType!==p.COMMENT_NODE&&(r.__cnt++,null==r[a]?(r[a]=h(o,e+"."+a),m(r,a,e+"."+a)):(r[a]instanceof Array||(r[a]=[r[a]],m(r,a,e+"."+a)),r[a][r[a].length]=h(o,e+"."+a)))}for(var s=0;s<t.attributes.length;s++){var c=t.attributes.item(s);r.__cnt++;for(var l=c.value,u=0;u<d.attributeConverters.length;u++){var f=d.attributeConverters[u];f.test.call(null,c.name,c.value)&&(l=f.convert.call(null,c.name,c.value))}r[d.attributePrefix+c.name]=l}var _=t.prefix;return _&&(r.__cnt++,r.__prefix=_),r["#text"]&&(r.__text=r["#text"],r.__text instanceof Array&&(r.__text=r.__text.join("\n")),d.escapeMode&&(r.__text=r.__text.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")),d.stripWhitespaces&&(r.__text=r.__text.trim()),delete r["#text"],"property"===d.arrayAccessForm&&delete r["#text_asArray"],r.__text=function(t,e,r){if(0<d.datetimeAccessFormPaths.length)for(var n=r.split(".#")[0],i=0;i<d.datetimeAccessFormPaths.length;i++){var o=d.datetimeAccessFormPaths[i];if("string"==typeof o){if(o===n)return x(t)}else if(o instanceof RegExp){if(o.test(n))return x(t)}else if("function"==typeof o&&o(n))return x(t)}return t}(r.__text,0,e+".#text")),r.hasOwnProperty("#cdata-section")&&(r.__cdata=r["#cdata-section"],delete r["#cdata-section"],"property"===d.arrayAccessForm&&delete r["#cdata-section_asArray"]),1===r.__cnt&&r.__text?r=r.__text:0===r.__cnt&&"text"===d.emptyNodeForm?r="":1<r.__cnt&&void 0!==r.__text&&d.skipEmptyTextNodesForObj&&(d.stripWhitespaces&&""===r.__text||""===r.__text.trim())&&delete r.__text,delete r.__cnt,d.keepCData||r.hasOwnProperty("__text")||!r.hasOwnProperty("__cdata")||1!==Object.keys(r).length?(d.enableToStringFunc&&(r.__text||r.__cdata)&&(r.toString=function(){return(this.__text?this.__text:"")+(this.__cdata?this.__cdata:"")}),r):r.__cdata?r.__cdata:""}function h(t,e){return t.nodeType===p.DOCUMENT_NODE?function(t){for(var e={},r=t.childNodes,n=0;n<r.length;n++){var i=r.item(n);if(i.nodeType===p.ELEMENT_NODE){var o=g(i);d.ignoreRoot?e=h(i,o):e[o]=h(i,o)}}return e}(t):t.nodeType===p.ELEMENT_NODE?r(t,e):t.nodeType===p.TEXT_NODE||t.nodeType===p.CDATA_SECTION_NODE?t.nodeValue:null}function o(t,e,r,n){var i="<"+(t&&t.__prefix?t.__prefix+":":"")+e;if(r)for(var o=0;o<r.length;o++){var a=r[o],s=t[a];d.escapeMode&&(s=c(s)),i+=" "+a.substr(d.attributePrefix.length)+"=",d.useDoubleQuotes?i+='"'+s+'"':i+="'"+s+"'"}return i+=n?" />":">"}function i(t,e){return"</"+(t&&t.__prefix?t.__prefix+":":"")+e+">"}function a(t,e){return"property"===d.arrayAccessForm&&(r=e.toString(),n="_asArray",-1!==r.indexOf(n,r.length-n.length))||0===e.toString().indexOf(d.attributePrefix)||0===e.toString().indexOf("__")||t[e]instanceof Function;var r,n}function s(t){var e=0;if(t instanceof Object)for(var r in t)a(t,r)||e++;return e}function l(t){var e=[];if(t instanceof Object)for(var r in t)-1===r.toString().indexOf("__")&&0===r.toString().indexOf(d.attributePrefix)&&e.push(r);return e}function u(t){var e,r,n="";return t instanceof Object?n+=(r="",(e=t).__cdata&&(r+="<![CDATA["+e.__cdata+"]]>"),(e.__text||"number"==typeof e.__text||"boolean"==typeof e.__text)&&(d.escapeMode?r+=c(e.__text):r+=e.__text),r):null!==t&&(d.escapeMode?n+=c(t):n+=t),n}function f(t,e,r){var n="";if(d.jsAttributeFilter&&d.jsAttributeFilter.call(null,e,t))return n;if(d.jsAttributeConverter&&(t=d.jsAttributeConverter.call(null,e,t)),null!=t&&""!==t||!d.selfClosingElements)if("object"==typeof t)if("[object Array]"===Object.prototype.toString.call(t))n+=function(t,e,r){var n="";if(0===t.length)n+=o(t,e,r,!0);else for(var i=0;i<t.length;i++)n+=f(t[i],e,l(t[i]));return n}(t,e,r);else if(t instanceof Date)n+=o(t,e,r,!1),n+=d.jsDateUTC?t.toUTCString():t.toISOString(),n+=i(t,e);else{0<s(t)||"number"==typeof t.__text||"boolean"==typeof t.__text||t.__text||t.__cdata?(n+=o(t,e,r,!1),n+=_(t),n+=i(t,e)):d.selfClosingElements?n+=o(t,e,r,!0):(n+=o(t,e,r,!1),n+=i(t,e))}else n+=o(t,e,r,!1),n+=u(t),n+=i(t,e);else n+=o(t,e,r,!0);return n}function _(t){var e="";if(0<s(t))for(var r in t)if(!a(t,r)){var n=t[r];e+=f(n,r,l(n))}return e+=u(t)}function n(t){if(void 0===t)return null;if("string"!=typeof t)return null;var e=null,r=null;if(y)r=(e=new y(d.xmldomOptions)).parseFromString(t,"text/xml");else if(window&&window.DOMParser){e=new window.DOMParser;var n=null;if(!(window.ActiveXObject||"ActiveXObject"in window)&&document.all&&!document.addEventListener)try{n=e.parseFromString("INVALID","text/xml").childNodes[0].namespaceURI}catch(t){n=null}try{r=e.parseFromString(t,"text/xml"),null!==n&&0<r.getElementsByTagNameNS(n,"parsererror").length&&(r=null)}catch(t){r=null}}else 0===t.indexOf("<?")&&(t=t.substr(t.indexOf("?>")+2)),(r=new ActiveXObject("Microsoft.XMLDOM")).async="false",r.loadXML(t);return r}this.asArray=function(t){return null==t?[]:t instanceof Array?t:[t]},this.toXmlDateTime=function(t){return t instanceof Date?t.toISOString():"number"==typeof t?new Date(t).toISOString():null},this.asDateTime=function(t){return"string"==typeof t?x(t):t},this.xml2dom=function(t){return n(t)},this.dom2js=function(t){return h(t,null)},this.js2dom=function(t){return n(this.js2xml(t))},this.xml2js=function(t){var e=n(t);return null!=e?this.dom2js(e):null},this.js2xml=function(t){return _(t)},this.getVersion=function(){return"3.1.1"}}}); | ||
//# sourceMappingURL=x2js.min.js.map |
{ | ||
"name": "x2js", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "Transforms between XML string and JavaScript object trees.", | ||
@@ -5,0 +5,0 @@ "main": "x2js.js", |
@@ -663,3 +663,3 @@ /* | ||
// IE9+ now is here | ||
if (!isIEParser) { | ||
if (!isIEParser && document.all && !document.addEventListener) { | ||
try { | ||
@@ -666,0 +666,0 @@ parsererrorNS = parser.parseFromString("INVALID", "text/xml").childNodes[0].namespaceURI; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
117313
19