UNPKG

14.1 kBJavaScriptView Raw
1var XMLLite=function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="/",e(0)}([function(t,e,n){"use strict";mocha.setup("bdd"),n(34),n(35),n(36),n(39),n(40),mocha.run()},,function(t,e){t.exports=jQuery},,function(t,e){t.exports=XMLLite},function(t,e,n){"use strict";var o=n(6),i=n(9),r=n(8),u=n(10),c=n(11),f=n(7);t.exports=u.extend({global:i},o,r,u,c,f)},function(t,e,n){"use strict";function o(t){return"object"===("undefined"==typeof t?"undefined":l(t))&&d.isFinite(t.length)}function i(t){return o(t)?g.call(t):[]}function r(t){return g.call(t,1)}function u(t,e,n){return t.apply(e,r(n))}function c(t,e){return y(i(t),e)>-1}function f(t){var e=[];return v(t,function(t){c(e,t)||e.push(t)}),e}function a(t){for(var e=i(t),n=[],r=0,u=e.length;r<u;++r)o(e[r])?n=n.concat(e[r]):n[n.length]=e[r];return n}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=n(7),d=n(8),h=s.isArray,m=Array.prototype,g=m.slice,p=function(t){return function(e,n,o){var i=void 0,r=e.length>>>0;if(0===r)return-1;if(o?o<0&&(o=Math.max(0,e.length+o)):o=t?0:e.length,t){for(i=o;i<e.length;i++)if(e[i]===n)return i}else for(i=o;i>=0;i--)if(e[i]===n)return i;return-1}},y=m.indexOf?function(t){return u(m.indexOf,t,arguments)}:p(!0),b=m.lastIndexOf?function(t){return u(m.lastIndexOf,t,arguments)}:p(),v=m.forEach?function(t){u(m.forEach,t,arguments)}:function(t,e,n){for(var o=i(t),r=0;r<o.length;r++)e.call(n,o[r],r,t)},N=m.every?function(t){return u(m.every,t,arguments)}:function(t,e,n){for(var o=i(t),r=0;r<o.length;r++)if(!e.call(n,o[r],r,t))return!1;return!0},x=m.filter?function(t){return u(m.filter,t,arguments)}:function(t,e,n){var o=[];return v(t,function(i,r){e.call(n,i,r,t)&&o.push(i)}),o},L=m.map?function(t){return u(m.map,t,arguments)}:function(t,e,n){var o=[];return v(t,function(i,r){o.push(e.call(n,i,r,t))}),o},w=m.some?function(t){return u(m.some,t,arguments)}:function(t,e,n){var o=void 0;for(o=0;o<t.length;o++)if(e.call(n,t[o],o,t))return!0;return!1},M=m.reduce?function(t){return u(m.reduce,t,arguments)}:function(t,e,n){var o=void 0;n&&(o=n);for(var i=0;i<t.length;i++)o=o?e(o,t[i],i,t):t[i];return o},j=m.reduceRight?function(t){return u(m.reduceRight,t,arguments)}:function(t,e,n){var o=void 0;n&&(o=n);for(var i=t.length-1;i>=0;i--)o=o?e(o,t[i],i,t):t[i];return o},k={contains:c,each:v,every:N,filter:x,flatten:a,index:p,indexOf:y,isArray:h,isArrayLike:o,lastIndexOf:b,map:L,reduce:M,reduceRight:j,some:w,toArray:i,uniq:f,forEach:v,difference:function(t){var e=a(r(arguments));return x(t,function(t){return!c(e,t)})},eachReverse:function(t,e,n){for(var o=i(t),r=o.length-1;r>-1;r-=1)e.call(n,o[r],r,t)},intersect:function(t,e){var n=[];return v(t,function(t){c(e,t)&&n.push(t)}),n},range:function t(e,n,o){null==n&&(n=e||0,e=0),o||(o=n<e?-1:1);for(var i=Math.max(Math.ceil((n-e)/o),0),t=new Array(i),r=0;r<i;r++,e+=o)t[r]=e;return t},remove:function(t,e,n){var o=t.length;if(!d.isNumber(e))return t;var i=t.slice((n||e)+1||o);return t.length=e<0?o+e:e,t.push.apply(t,i)},union:function(){var t=[],e=i(arguments);return v(e,function(e){t=t.concat(e)}),f(t)}};t.exports=k},function(t,e){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o={}.toString,i=function(t,e){return o.call(t)==="[object "+e+"]"},r={isType:i,isArguments:function(t){return i(t,"Arguments")},isArray:Array.isArray?Array.isArray:function(t){return i(t,"Array")},isArrayLike:function(t){return"object"===("undefined"==typeof t?"undefined":n(t))&&isFinite(t.length)},isBoolean:function(t){return i(t,"Boolean")},isDate:function(t){return i(t,"Date")},isError:function(t){return i(t,"Error")},isFunction:function(t){return i(t,"Function")},isNull:function(t){return null===t},isNumber:function(t){return i(t,"Number")},isPlainObject:function(t){return i(t,"Object")},isRegExp:function(t){return i(t,"RegExp")},isString:function(t){return i(t,"String")},isUndefined:function(t){return void 0===t},getType:function(t){var e=o.call(t);return e.replace(/^\[object /,"").replace(/\]$/,"")},isObject:function(t){var e="undefined"==typeof t?"undefined":n(t);return"function"===e||"object"===e&&!!t}};r.isNil=function(t){return r.isNull(t)||r.isUndefined(t)},t.exports=r},function(t,e,n){"use strict";var o=n(7),i=o.isNumber,r=Math.min,u=Math.max,c={isFinite:isFinite,isNaN:isNaN,isNumber:i,isDecimal:function(t){return i(t)&&t%1!==0},isEven:function(t){return i(t)&&t%2===0},isInteger:Number.isInteger?Number.isInteger:function(t){return i(t)&&t%1===0},isNegative:function(t){return i(t)&&t<0},isOdd:function(t){return i(t)&&t%2!==0},isPositive:function(t){return i(t)&&t>0},toFloat:function(t){return parseFloat(t)},toInteger:function(t,e){return parseInt(t,e||10)},isInRange:function(t,e,n){return e=+e||0,void 0===n?(n=e,e=0):n=+n||0,t>=r(e,n)&&t<u(e,n)}};c.isInFinite=function(t){return!c.isFinite(t)},t.exports=c},function(t,e){(function(e){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o="undefined",i={};("undefined"==typeof window?"undefined":n(window))!==o?i=window:("undefined"==typeof e?"undefined":n(e))!==o?i=e:("undefined"==typeof self?"undefined":n(self))!==o&&(i=self),t.exports=i}).call(e,function(){return this}())},function(t,e,n){"use strict";function o(t){return d(t)?t:{}}function i(t,e,n){var i=o(t);for(var r in i)({}).hasOwnProperty.call(i,r)&&e.call(n,i[r],r,t)}function r(t){var e=[];return i(t,function(t){e.push(t)}),e}function u(t){return t=t||{},g(y(arguments).slice(1),function(e){e&&i(e,function(n,o){t[o]=e[o]})}),t}function c(t){return t=t||{},g(y(arguments).slice(1),function(e){i(e,function(n,o){a(e[o])!==a(t[o])?d(e[o])?(t[o]={},c(t[o],e[o])):t[o]=e[o]:d(e[o])?c(t[o],e[o]):t[o]=e[o]})}),t}var f=n(7),a=f.getType,l=f.isFunction,s=f.isObject,d=f.isPlainObject,h=n(6),m=h.contains,g=h.each,p=h.isArrayLike,y=h.toArray,b=Object.keys?function(t){return Object.keys(t)}:function(t){var e=[];return i(t,function(n,o){l(t)&&"prototype"===o||e.push(o)}),e},v={extend:u,forIn:i,isObject:s,isPlainObject:d,keys:b,merge:c,values:r,assign:u,hasKey:function(t,e){return{}.hasOwnProperty.call(t,e)},hasValue:function(t,e){return m(r(t),e)},invert:function(t){var e={};return i(t,function(t,n){e[t]=n}),e},clone:function(t){return p(t)?y(t):d(t)?c({},t):t},destroy:function(t){i(t,function(e,n){delete t[n]}),t.prototype=null,t=null}};t.exports=v},function(t,e,n){"use strict";function o(t){return t.toString()}var i=n(7),r=i.isString,u=String.prototype,c={isString:r,trim:function(t){return t=o(t),u.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},trimLeft:function(t){return t=o(t),u.trimLeft?t.trimLeft():t.replace(/^\s+/g,"")},trimRight:function(t){return t=o(t),u.trimRight?t.trimRight():t.replace(/^\s+/g,"")},lc:function(t){return o(t).toLowerCase()},uc:function(t){return o(t).toUpperCase()},hasSubString:function(t,e){return o(t).indexOf(o(e))>-1}};t.exports=c},,,,,,,,,,,,,,,,,,,,,,,function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var i=n(4),r=o(i),u=chai.assert;describe("dom2js",function(){var t=document.createElement("div");t.innerHTML='hello, world!\n<a href="https://github.com/leungwensen/xml-lite">\n maintaining xml in pure javascript (IN BOTH NODE.JS & BROWSERS)\n</a>',t.setAttribute("class","test-div"),t.setAttribute("data-hello","world");var e=r.default.dom2js(t);it("Element: type and tag",function(){u.equal(e.type,t.ELEMENT_NODE,"XMLLite.dom2js() not working: type is not right."),u.equal(e.tag,"DIV","XMLLite.dom2js() not working: tag is not right.")}),it("Element: attributes",function(){u.deepEqual(e.attributes,{class:"test-div","data-hello":"world"},"XMLLite.dom2js() not working: something wrong with the attributes.")})})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var i=n(4),r=o(i),u=n(2),c=o(u),f=chai.assert;describe("dom-utils",function(){c.default.get("./fixtures/bookstore.xml",function(t){var e=r.default.parse(t);it("dom-utils: attributesAsObject(doc)",function(){f.deepEqual(r.default.attributesAsObject(r.default.findNodes(e,{tagName:"book",attributes:{category:"COOKING"}})[0]),{category:"COOKING"},"XMLLite.attributesAsObject(doc) not working: something wrong.")}),it("dom-utils: findChildNode(doc, query)",function(){f.equal(r.default.findChildNode(e,{nodeName:"PITarget"}).nodeName,"PITarget","XMLLite.findChildNode(doc, query) not working: not exists.")}),it("dom-utils: findChildNodes(doc, query)",function(){f.equal(r.default.findChildNodes(r.default.findChildNode(e,{tagName:"bookstore"}),{tagName:"book"}).length,3,"XMLLite.findChildNodes(doc, query) not working: result nodes count not matching.")}),it("dom-utils: findAllNodes(doc, query)",function(){f.equal(r.default.findAllNodes(r.default.findChildNode(e,{tagName:"bookstore"}),{tagName:"price"}).length,3,"XMLLite.findAllNodes(doc, query) not working: result nodes count not matching.")}),it("dom-utils: findChildNodes(doc, query) on an element that has no childNodes",function(){f.equal(r.default.findChildNodes(e.childNodes[0],{tagName:"book"}).length,0,"XMLLite.findChildNodes(doc, query) not working: result nodes count not matching.")}),it("dom-utils: createChildNode(doc, query)",function(){f.equal(r.default.createChildNode(e.documentElement,{tagName:"test"}).tagName,"test","XMLLite.createChildNode(doc, query) not working: failed.")}),it("dom-utils: findOrCreateChildNode(doc, query)",function(){f.equal(r.default.findOrCreateChildNode(e.documentElement,{tagName:"test"}).tagName,"test","XMLLite.findOrCreateChildNode(doc, query) not working: failed.")}),it("dom-utils: eachChildNode(doc, query, callback)",function(){f.doesNotThrow(function(){r.default.eachChildNode(e,{},function(t){console.log(t.nodeName)})},Error,"XMLLite.eachChildNode(doc, query, callback) not working: failed.")}),it("dom-utils: eachNode(doc, query, callback)",function(){f.doesNotThrow(function(){r.default.eachNode(e,{},function(t){console.log(t.nodeName)})},Error,"XMLLite.eachChildNode(doc, query, callback) not working: failed.")}),it("dom-utils: removeChildNode(doc, query)",function(){var t=e.childNodes.length;console.log(e.childNodes),f.doesNotThrow(function(){r.default.removeChildNode(e,{nodeName:"PITarget"})},Error,"XMLLite.eachChildNode(doc, query, callback) not working: failed."),f.equal(e.childNodes.length,t-1,"XMLLite.removeChildNode(doc, query) not working: failed."),console.log(e.childNodes)})},"text")})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var i=n(2),r=o(i),u=n(4),c=o(u),f=n(37),a=o(f),l=n(38),s=o(l),d=chai.assert;describe("js2xml",function(){function t(e){e.length&&!function(){var n=e.shift();it("js2xml: spec/fixtures/"+n+".xml",function(t){r.default.get("./fixtures/"+n+".xml",function(e){r.default.get("./fixtures/"+n+".json",function(o){var i=Date.now();c.default.js2xml(o);var r=Date.now()-i,u=(0,a.default)(o);console.log("%cjs2xml: %c%sms %cto render %c%s %celements in fixture "+n+".","font-weight: bold; color: blue;","font-weight: bold; color: green;",(0,s.default)(r,3),"font-weight: normal; color: black;","font-weight: bold; color: red;",(0,s.default)(u,4),"font-weight: normal; color: black;"),"mmap-content"!==n&&d.equal(c.default.js2xml(o),c.default.uglify(e),"test case by fixture "+n+" not passed"),t()})},"text")}),t(e)}()}this.timeout(1e4),r.default.get("./fixtures/files.json",function(e){t(e)})})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var i=n(5),r=o(i);t.exports=function(t){function e(t){"Document"!==t.type&&"TextNode"!==t.type&&n++,t.children&&r.default.each(t.children,function(t){e(t)})}var n=0;return e(t),n}},function(t,e){"use strict";t.exports=function(t,e,n){n=n||" ";for(var o=t.toString();o.length<e;)o=n+o;return o}},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var i=n(2),r=o(i),u=n(4),c=o(u),f=n(37),a=o(f),l=n(38),s=o(l),d=chai.assert;describe("xml2js",function(){function t(e){e.length&&!function(){var n=e.shift();it("xml2js: spec/fixtures/"+n+".xml",function(t){r.default.get("./fixtures/"+n+".xml",function(e){e=c.default.uglify(e,!0),r.default.get("./fixtures/"+n+".json",function(o){var i=Date.now(),r=c.default.xml2js(e),u=Date.now()-i,f=(0,a.default)(r);console.log("%cxml2js: %c%sms %cto parse %c%s %celements in fixture "+n+".","font-weight: bold; color: blue;","font-weight: bold; color: green;",(0,s.default)(u,3),"font-weight: normal; color: black;","font-weight: bold; color: red;",(0,s.default)(f,5),"font-weight: normal; color: black;"),d.deepEqual(c.default.xml2js(e),o,"test case by fixture "+n+" not passed"),t()})},"text")}),t(e)}()}this.timeout(1e4),r.default.get("./fixtures/files.json",function(e){t(e)})})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var i=n(4),r=o(i),u=chai.assert;describe("error tracking",function(){it("XMLLite.parse(): invalid xml",function(){u.throws(function(){r.default.parse("some text")},"invalid XML"),u.throws(function(){r.default.parse("<xx")},"invalid XML"),u.throws(function(){r.default.parse("<test/><!--")},"invalid XML")}),it("XMLLite.parse(): empty document",function(){u.throws(function(){r.default.parse("")},"invalid XML")}),it("XMLLite.parse(): unclosed tag",function(){u.throws(function(){r.default.parse("<img>")},"invalid XML")}),it("XMLLite.parse(): attribute missing qute",function(){u.throws(function(){r.default.parse("<img src=1/>")},"invalid XML")}),it("XMLLite.parse(): invalid attribute",function(){u.throws(function(){r.default.parse('<img src="<>&"/>')},"invalid XML")})})}]);
\No newline at end of file