diff --git a/CHANGELOG.md b/CHANGELOG.md
index a62cadc..a5ad9d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,9 +2,14 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+[1.5.1] - 2018-12-22
+---------------------
+##### Fixed
+- Installation of this library with `npm install enketo-validate` fails.
+
[1.5.0] - 2018-12-21
---------------------
-#### Added
+##### Added
- Detect disallowed logic references to node itself.
#### Changed
diff --git a/build/.gitignore b/build/.gitignore
deleted file mode 100644
index c96a04f..0000000
--- a/build/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
\ No newline at end of file
diff --git a/build/FormModel-bundle.js b/build/FormModel-bundle.js
new file mode 100644
index 0000000..10a8548
--- /dev/null
+++ b/build/FormModel-bundle.js
@@ -0,0 +1,49908 @@
+(function () {
+ 'use strict';
+
+ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
+
+ function createCommonjsModule(fn, module) {
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
+ }
+
+ var mergexml = createCommonjsModule(function (module, exports) {
+ /**
+ * XML merging class
+ * Merge multiple XML sources
+ *
+ * @package MergeXML
+ * @author Vallo Reima
+ * @copyright (C)2014-2016
+ */
+
+ /**
+ * AMD/CommonJS wrapper
+ * @param {object} root
+ * @param {function} factory
+ */
+ (function(root, factory) {
+ {
+ // Does not work with strict CommonJS,
+ // but only CommonJS-like environments
+ // that support module.exports, like Node
+ module.exports = factory();
+ }
+ }(commonjsGlobal, function() {
+ /**
+ * Return a function as the exported value
+ * @param {object} opts -- stay, join, updn (see readme)
+ */
+ return function(opts) {
+
+ var mde; /* access mode 0,1,2 */
+ var msv; /* MS DOM version */
+ var psr; /* DOM parser object */
+ var nse; /* parsererror namespace */
+ var xpe; /* xPath evaluator */
+ var nsr; /* namespace resolver */
+ var nsd = '_'; /* default namespace prefix */
+ var stay; /* overwrite protection */
+ var join; /* joining root name and status*/
+ var updn; /* update nodes sequentially by name */
+ var XML_ELEMENT_NODE = 1;
+ var XML_TEXT_NODE = 3;
+ var XML_COMMENT_NODE = 8;
+ var XML_PI_NODE = 7;
+ var that = this;
+
+ that.Init = function() {
+ that.dom = null; /* result DOM object */
+ that.nsp = {}; /* namespaces */
+ that.count = 0; /* adding counter */
+ join[1] = false;
+ if (mde > 0) {
+ that.error = {code: '', text: ''};
+ }
+ return (mde > 0);
+ };
+
+ /**
+ * add XML file
+ * @param {object} file -- FileList element
+ * @return {object|false}
+ */
+ that.AddFile = function(file) {
+ var rlt;
+ if (!file || !file.target) {
+ rlt = Error('nof');
+ } else if (!file.target.result) {
+ rlt = Error('emf');
+ } else {
+ rlt = that.AddSource(file.target.result);
+ }
+ return rlt;
+ };
+
+ /**
+ * add XML string
+ * @param {string|oobject} xml
+ * @return mixed -- false - bad content
+ * object - result
+ */
+ that.AddSource = function(xml) {
+ var rlt, doc;
+ if (typeof xml === 'object') {
+ doc = that.Get(1, xml) ? xml : false;
+ if (doc && ((mde === 1 && !window.DOMParser) || (mde === 2 && !doc.selectSingleNode('/')))) {
+ doc = null; /* not compatible */
+ }
+ } else {
+ try {
+ doc = Load(xml);
+ } catch (e) {
+ doc = false;
+ }
+ }
+ if (doc === null) {
+ rlt = Error('nos');
+ } else if (doc === false) {
+ rlt = Error('inv');
+ } else if (doc === true) {
+ that.nsp = NameSpaces(that.dom.documentElement);
+ that.count = 1;
+ rlt = that.dom;
+ } else if (CheckSource(doc)) {
+ Merge(doc, '/'); /* add to existing */
+ if (join[1] === true) {
+ var tmp = that.dom.createTextNode("\r\n");
+ that.dom.documentElement.appendChild(tmp);
+ }
+ that.count++;
+ rlt = that.dom;
+ } else {
+ rlt = false;
+ }
+ return rlt;
+ };
+
+ /**
+ * load the source into dom object
+ * @param {object|string} src -- the source
+ * @return {mixed} -- false - error
+ * true - 1st load
+ * object - loaded doc
+ */
+ var Load = function(src) {
+ var rlt, doc;
+ if (mde === 1) {
+ if (that.dom) {
+ doc = psr.parseFromString(src, 'text/xml');
+ rlt = ParseError(doc) ? doc : false;
+ } else {
+ that.dom = psr.parseFromString(src, 'text/xml');
+ rlt = ParseError(that.dom) ? true : false;
+ }
+ } else if (that.dom) {
+ doc = new ActiveXObject(msv);
+ doc.async = false;
+ rlt = doc.loadXML(src) ? doc : false;
+ } else {
+ that.dom = new ActiveXObject(msv);
+ that.dom.async = false;
+ that.dom.setProperty('SelectionLanguage', 'XPath');
+ rlt = that.dom.loadXML(src) ? true : false;
+ }
+ return rlt;
+ };
+
+ /**
+ * check for xml syntax (mode 1)
+ * @param {object} doc
+ * @return {bool} -- true - ok
+ */
+ var ParseError = function(doc) {
+ return doc.getElementsByTagNameNS(nse, 'parsererror').length === 0;
+ };
+
+ /**
+ *
+ * @param {object} doc
+ * @return {bool} -- true - ok
+ */
+ var CheckSource = function(doc) {
+ var rlt = true;
+ var charSet1 = that.dom.characterSet || that.dom.inputEncoding || that.dom.xmlEncoding;
+ var charSet2 = doc.characterSet || doc.inputEncoding || doc.xmlEncoding;
+ if (charSet2 !== charSet1) {
+ rlt = Error('enc');
+ } else if (doc.documentElement.namespaceURI !== that.dom.documentElement.namespaceURI) { /* $dom->documentElement->lookupnamespaceURI(NULL) */
+ rlt = Error('nse');
+ } else if (doc.documentElement.nodeName !== that.dom.documentElement.nodeName) {
+ if (!join[0]) {
+ rlt = Error('dif');
+ } else if (!join[1]) {
+ var enc = typeof charSet1 !== 'undefined' ? charSet1 : 'UTF-8';
+ var ver = that.dom.xmlVersion ? that.dom.xmlVersion : '1.0';
+ var xml = '\r\n<" + join[0] + ">\r\n" + join[0] + '>';
+ var d = Load(xml);
+ if (d) {
+ var tmp = that.dom.documentElement.cloneNode(true);
+ d.documentElement.appendChild(tmp);
+ tmp = d.createTextNode("\r\n");
+ d.documentElement.appendChild(tmp);
+ that.dom = d;
+ join[1] = true;
+ } else {
+ rlt = Error('jne');
+ join[1] = null;
+ }
+ }
+ }
+ if (rlt) {
+ var a = NameSpaces(doc.documentElement);
+ for (var c in a) {
+ if (!that.nsp[c]) {
+ if (typeof that.dom.documentElement.setAttributeNS !== 'undefined') {
+ that.dom.documentElement.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:' + c, a[c]);
+ } else {
+ // no choice but to use the incorrect setAttribute instead
+ that.dom.documentElement.setAttribute('xmlns:' + c, a[c]);
+ }
+ that.nsp[c] = a[c];
+ }
+ }
+ if (!updn) {
+ nsr = null;
+ } else if (mde === 1) {
+ nsr = Resolver;
+ } else {
+ ResolverIE();
+ }
+ }
+ return rlt;
+ };
+ /**
+ * join 2 dom objects recursively
+ * @param {object} src -- current source node
+ * @param {string} pth -- current source path
+ */
+ var Merge = function(src, pth) {
+ for (var i = 0; i < src.childNodes.length; i++) {
+ var tmp;
+ var node = src.childNodes[i]; //$node->getNodePath()
+ var path = GetNodePath(src.childNodes, node, pth, i);
+ var obj = that.Query(path);
+ if (node.nodeType === XML_ELEMENT_NODE) {
+ var flg = true; /* replace existing node by default */
+ if (obj === null || obj.namespaceURI !== node.namespaceURI) {
+ tmp = node.cloneNode(true); /* take existing node */
+ obj = that.Query(pth); /* destination parent */
+ obj.appendChild(tmp); /* add a node */
+ } else {
+ if (ArraySearch(obj.getAttribute('stay'), stay) !== false) {
+ flg = false; /* don't replace */
+ }
+ if (flg) {
+ try {
+ for (var j = 0; j < node.attributes.length; j++) { /* add/replace attributes */
+ if (node.attributes[j].namespaceURI && typeof node.setAttributeNS !== 'undefined') {
+ obj.setAttributeNS(node.attributes[j].namespaceURI, node.attributes[j].nodeName, node.attributes[j].nodeValue);
+ } else {
+ obj.setAttribute(node.attributes[j].nodeName, node.attributes[j].nodeValue);
+ }
+ }
+ } catch (e) {
+ /* read-only node */
+ }
+ }
+ }
+ if (node.hasChildNodes() && flg) {
+ Merge(node, path); /* go to subnodes */
+ }
+ } else if (node.nodeType === XML_TEXT_NODE || node.nodeType === XML_COMMENT_NODE) { /* leaf node */
+ if (obj === null || obj.nodeType !== node.nodeType) {
+ obj = that.Query(pth); /* destination parent node */
+ if (node.nodeType === XML_TEXT_NODE) {
+ tmp = that.dom.createTextNode(node.nodeValue); /* add text */
+ } else {
+ tmp = that.dom.createComment(node.nodeValue); /* add comment */
+ }
+ obj.appendChild(tmp); /* add leaf */
+ } else {
+ obj.nodeValue = node.nodeValue; /* replace leaf */
+ }
+ }
+ }
+ };
+
+ /**
+ * form the node xPath
+ * @param {object} nodes -- child nodes
+ * @param {object} node -- current child
+ * @param {string} pth -- parent path
+ * @param {int} eln -- element sequence number
+ * @return {string} query path
+ */
+ var GetNodePath = function(nodes, node, pth, eln) {
+ var p, i;
+ var j = 0;
+ if (node.nodeType === XML_ELEMENT_NODE) {
+ for (i = 0; i <= eln; i++) {
+ if ((updn && nodes[i].nodeType === node.nodeType && nodes[i].nodeName === node.nodeName) ||
+ (!updn && nodes[i].nodeType !== XML_PI_NODE)) {
+ j++;
+ }
+ }
+ if (updn) {
+ var f = false;
+ var a = NameSpaces(node);
+ for (var c in a) {
+ if (c !== nsd) {
+ that.nsp[c] = a[c];
+ f = (mde === 2);
+ }
+ }
+ if (f) {
+ ResolverIE();
+ }
+ if (node.prefix) {
+ p = node.prefix + ':';
+ } else if (that.nsp[nsd]) {
+ p = nsd + ':';
+ } else {
+ p = '';
+ }
+ p += (node.localName ? node.localName : node.baseName);
+ } else {
+ p = 'node()';
+ }
+ } else if (node.nodeType === XML_TEXT_NODE || node.nodeType === XML_COMMENT_NODE) {
+ for (i = 0; i <= eln; i++) {
+ if (nodes[i].nodeType === node.nodeType) {
+ j++;
+ }
+ }
+ p = node.nodeType === XML_TEXT_NODE ? 'text()' : 'comment()';
+ } else {
+ p = pth;
+ }
+ if (j) {
+ p = pth + (pth.slice(-1) === '/' ? '' : '/') + p + '[' + j + ']';
+ }
+ return p;
+ };
+
+ /**
+ * get node's namespaces
+ * @param {object} node
+ * @return {array}
+ */
+ var NameSpaces = function(node) {
+ var rlt = {};
+ var attrs = node.attributes;
+ for (var i = 0; i < attrs.length; ++i) {
+ var a = attrs[i].name.split(':');
+ if (a[0] === 'xmlns') {
+ var c = a[1] ? a[1] : nsd;
+ rlt[c] = attrs[i].value;
+ }
+ }
+ return rlt;
+ };
+
+ /**
+ * xPath query
+ * @param {string} qry -- query statement
+ * @return {object}
+ */
+ that.Query = function(qry) {
+ var rlt;
+ if (join[1]) {
+ qry = '/' + that.dom.documentElement.nodeName + (qry === '/' ? '' : qry);
+ }
+ try {
+ if (mde === 1) {
+ rlt = xpe.evaluate(qry, that.dom, nsr, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
+ rlt = rlt.singleNodeValue;
+ } else {
+ rlt = that.dom.selectSingleNode(qry);
+ }
+ }
+ catch (e) {
+ rlt = null; /* no such path */
+ }
+ return rlt;
+ };
+
+ /**
+ * XPathNSResolver
+ * @param {string} pfx node prefix
+ * @return {string} namespace URI
+ */
+ var Resolver = function(pfx) {
+ return that.nsp[pfx] || null;
+ };
+
+ /**
+ * XPath IE Resolver
+ */
+ var ResolverIE = function() {
+ var p = '';
+ for (var c in that.nsp) {
+ p += ' xmlns:' + c + '=' + "'" + that.nsp[c] + "'";
+ }
+ if (p) {
+ that.dom.setProperty('SelectionNamespaces', p.substr(1));
+ }
+ };
+
+ /**
+ * find array memeber by value
+ * @param {mixed} val
+ * @param {array} arr
+ * @returns {mixed}
+ */
+ var ArraySearch = function(val, arr) {
+ var rlt = false;
+ for (var key in arr) {
+ if (arr[key] === val) {
+ rlt = key;
+ break;
+ }
+ }
+ return rlt;
+ };
+
+ /**
+ * get result
+ * @param {int} flg -- 0 - object
+ * 1 - xml
+ * 2 - html
+ * @param {object} doc
+ * @return {mixed}
+ */
+ that.Get = function(flg, doc) {
+ var rlt;
+ if (flg && !doc) {
+ doc = that.dom;
+ }
+ if (!flg) {
+ rlt = that.dom;
+ } else if (!doc) {
+ rlt = '';
+ } else if (doc.xml) {
+ rlt = doc.xml;
+ } else {
+ try {
+ rlt = (new XMLSerializer()).serializeToString(doc);
+ } catch (e) {
+ rlt = null;
+ }
+ }
+ if (rlt && flg === 2) { /* make html view */
+ if (join[1]) {
+ var k = rlt.indexOf('<' + join[0]);
+ rlt = rlt.substr(0, k) + "\r\n" + rlt.substr(k);
+ }
+ rlt = rlt.replace(//g, '>').replace(/ |\t/g, ' '); /* tags and spaces */
+ rlt = rlt.replace(/(\r\n|\n|\r)/g, '
'); /* line breaks */
+ }
+ return rlt;
+ };
+
+ /**
+ * set error message
+ * @param {string} err -- token
+ * @return {false}
+ */
+ var Error = function(err) {
+ var errs = {
+ nod: 'XML DOM is not supported in this browser',
+ nox: 'xPath is not supported in this browser',
+ nos: 'Incompatible source object',
+ nof: 'File not found',
+ emf: 'File is empty', /* possible delivery fault */
+ inv: 'Invalid XML source',
+ enc: 'Different encoding',
+ dif: 'Different root nodes',
+ jne: 'Invalid join parameter',
+ nse: 'Namespace incompatibility',
+ und: 'Undefined error'
+ };
+ that.error.code = errs[err] ? err : 'und';
+ that.error.text = errs[that.error.code];
+ return false;
+ };
+
+ /**
+ * identify browser functionality
+ * @return {int|string} mode number or error code
+ */
+ var GetMode = function() {
+ var m;
+ var f = false;
+ var vers = [
+ 'MSXML2.DOMDocument.6.0',
+ 'MSXML2.DOMDocument.3.0',
+ 'MSXML2.DOMDocument',
+ 'Microsoft.XmlDom'
+ ];
+ var n = vers.length;
+ for (var i = 0; i < n; i++) {
+ try {
+ var d = new ActiveXObject(vers[i]);
+ d.async = false;
+ f = true; /* DOM supported */
+ if (d.loadXML('') && d.selectSingleNode('/')) {
+ break; /* xPath supported */
+ }
+ } catch (e) {
+ /* skip */
+ }
+ }
+ if (f) {
+ if (i < n) {
+ msv = vers[i];
+ m = 2; /* IE mode */
+ } else {
+ m = 'nox'; /* no xPath */
+ }
+ } else if (!window.DOMParser) {
+ m = 'nod'; /* no DOM */
+ } else if (!window.XPathEvaluator) {
+ m = 'nox'; /* no xPath */
+ } else {
+ psr = new DOMParser();
+ var e = psr.parseFromString('Invalid', 'text/xml'); /* to detect source error */
+ nse = e.getElementsByTagName('parsererror')[0].namespaceURI;
+ xpe = new XPathEvaluator();
+ m = 1; /* Firefox, Safari, Chrome, Opera */
+ }
+ return m;
+ };
+
+ if (typeof opts !== 'object') {
+ opts = {};
+ }
+ /* set stay attribute value to check */
+ if (typeof opts.stay === 'undefined') {
+ stay = ['all'];
+ } else if (!opts.stay) {
+ stay = [];
+ } else if (typeof opts.stay === 'object' && opts.stay instanceof Array) {
+ stay = opts.stay;
+ } else {
+ stay = [opts.stay];
+ }
+ /* set join condtion for different roots */
+ if (typeof opts.join === 'undefined') {
+ join = ['root'];
+ } else {
+ join = [opts.join ? String(opts.join) : false];
+ }
+ /* set update sequence manner */
+ if (typeof opts.updn === 'undefined') {
+ updn = true;
+ } else {
+ updn = opts.updn;
+ }
+ /* detect browser features: 2 - IE, 1 - rest, 0 - N/A */
+ mde = GetMode();
+ if (typeof mde === 'string') {
+ that.error = {};
+ Error(mde);
+ mde = 0;
+ }
+ that.Init();
+ };
+ }));
+ });
+
+ /* global ArrayBuffer, Uint8Array */
+ let cookies;
+
+ /**
+ * Parses an Expression to extract all function calls and theirs argument arrays.
+ *
+ * @param {String} expr The expression to search
+ * @param {String} func The function name to search for
+ * @return {>} The result array, where each result is an array containing the function call and array of arguments.
+ */
+ function parseFunctionFromExpression( expr, func ) {
+ let index;
+ let result;
+ let openBrackets;
+ let start;
+ let argStart;
+ let args;
+ const findFunc = new RegExp( `${func}\\s*\\(`, 'g' );
+ const results = [];
+
+ if ( !expr || !func ) {
+ return results;
+ }
+
+ while ( ( result = findFunc.exec( expr ) ) !== null ) {
+ openBrackets = 1;
+ args = [];
+ start = result.index;
+ argStart = findFunc.lastIndex;
+ index = argStart - 1;
+ while ( openBrackets !== 0 && index < expr.length ) {
+ index++;
+ if ( expr[ index ] === '(' ) {
+ openBrackets++;
+ } else if ( expr[ index ] === ')' ) {
+ openBrackets--;
+ } else if ( expr[ index ] === ',' && openBrackets === 1 ) {
+ args.push( expr.substring( argStart, index ).trim() );
+ argStart = index + 1;
+ }
+ }
+ // add last argument
+ if ( argStart < index ) {
+ args.push( expr.substring( argStart, index ).trim() );
+ }
+
+ // add [ 'function( a ,b)', ['a','b'] ] to result array
+ results.push( [ expr.substring( start, index + 1 ), args ] );
+ }
+
+ return results;
+ }
+
+ function stripQuotes( str ) {
+ if ( /^".+"$/.test( str ) || /^'.+'$/.test( str ) ) {
+ return str.substring( 1, str.length - 1 );
+ }
+ return str;
+ }
+
+ // Because iOS gives any camera-provided file the same filename, we need to a
+ // unique-ified filename.
+ //
+ // See https://github.com/kobotoolbox/enketo-express/issues/374
+ function getFilename( file, postfix ) {
+ let filenameParts;
+ if ( typeof file === 'object' && file !== null && file.name ) {
+ postfix = postfix || '';
+ filenameParts = file.name.split( '.' );
+ if ( filenameParts.length > 1 ) {
+ filenameParts[ filenameParts.length - 2 ] += postfix;
+ } else if ( filenameParts.length === 1 ) {
+ filenameParts[ 0 ] += postfix;
+ }
+ return filenameParts.join( '.' );
+ }
+ return '';
+ }
+
+ /**
+ * Converts NodeLists or DOMtokenLists to an array
+ * @param {[type]} list [description]
+ * @return {[type]} [description]
+ */
+ function toArray( list ) {
+ const array = [];
+ // iterate backwards ensuring that length is an UInt32
+ for ( let i = list.length >>> 0; i--; ) {
+ array[ i ] = list[ i ];
+ }
+ return array;
+ }
+
+ function isNumber( n ) {
+ return !isNaN( parseFloat( n ) ) && isFinite( n );
+ }
+
+ function readCookie( name ) {
+ let c;
+ let C;
+ let i;
+
+ if ( cookies ) {
+ return cookies[ name ];
+ }
+
+ c = document.cookie.split( '; ' );
+ cookies = {};
+
+ for ( i = c.length - 1; i >= 0; i-- ) {
+ C = c[ i ].split( '=' );
+ // decode URI
+ C[ 1 ] = decodeURIComponent( C[ 1 ] );
+ // if cookie is signed (using expressjs/cookie-parser/), extract value
+ if ( C[ 1 ].substr( 0, 2 ) === 's:' ) {
+ C[ 1 ] = C[ 1 ].slice( 2 );
+ C[ 1 ] = C[ 1 ].slice( 0, C[ 1 ].lastIndexOf( '.' ) );
+ }
+ cookies[ C[ 0 ] ] = decodeURIComponent( C[ 1 ] );
+ }
+
+ return cookies[ name ];
+ }
+
+ function dataUriToBlobSync( dataURI ) {
+ let byteString;
+ let mimeString;
+ let buffer;
+ let array;
+
+ // convert base64 to raw binary data held in a string
+ // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
+ byteString = atob( dataURI.split( ',' )[ 1 ] );
+ // separate out the mime component
+ mimeString = dataURI.split( ',' )[ 0 ].split( ':' )[ 1 ].split( ';' )[ 0 ];
+
+ // write the bytes of the string to an ArrayBuffer
+ buffer = new ArrayBuffer( byteString.length );
+ array = new Uint8Array( buffer );
+
+ for ( let i = 0; i < byteString.length; i++ ) {
+ array[ i ] = byteString.charCodeAt( i );
+ }
+
+ // write the ArrayBuffer to a blob
+ return new Blob( [ array ], {
+ type: mimeString
+ } );
+ }
+
+ function getPasteData( event ) {
+ const clipboardData = event.originalEvent.clipboardData || window.clipboardData; // modern || IE11
+ return ( clipboardData ) ? clipboardData.getData( 'text' ) : null;
+ }
+
+ /**
+ * Update a HTML anchor to serve as a download or reset it if an empty objectUrl is provided.
+ *
+ * @param {HTMLElement} anchor the anchor element
+ * @param {*} objectUrl the objectUrl to download
+ * @param {*} fileName the filename of the file
+ */
+ function updateDownloadLink( anchor, objectUrl, fileName ) {
+ if ( window.updateDownloadLinkIe11 ) {
+ return window.updateDownloadLinkIe11( ...arguments );
+ }
+ anchor.setAttribute( 'href', objectUrl || '' );
+ anchor.setAttribute( 'download', fileName || '' );
+ }
+
+ var jquery = createCommonjsModule(function (module) {
+ /*!
+ * jQuery JavaScript Library v3.3.1
+ * https://jquery.com/
+ *
+ * Includes Sizzle.js
+ * https://sizzlejs.com/
+ *
+ * Copyright JS Foundation and other contributors
+ * Released under the MIT license
+ * https://jquery.org/license
+ *
+ * Date: 2018-01-20T17:24Z
+ */
+ ( function( global, factory ) {
+
+ {
+
+ // For CommonJS and CommonJS-like environments where a proper `window`
+ // is present, execute the factory and get jQuery.
+ // For environments that do not have a `window` with a `document`
+ // (such as Node.js), expose a factory as module.exports.
+ // This accentuates the need for the creation of a real `window`.
+ // e.g. var jQuery = require("jquery")(window);
+ // See ticket #14549 for more info.
+ module.exports = global.document ?
+ factory( global, true ) :
+ function( w ) {
+ if ( !w.document ) {
+ throw new Error( "jQuery requires a window with a document" );
+ }
+ return factory( w );
+ };
+ }
+
+ // Pass this if window is not defined yet
+ } )( typeof window !== "undefined" ? window : commonjsGlobal, function( window, noGlobal ) {
+
+ var arr = [];
+
+ var document = window.document;
+
+ var getProto = Object.getPrototypeOf;
+
+ var slice = arr.slice;
+
+ var concat = arr.concat;
+
+ var push = arr.push;
+
+ var indexOf = arr.indexOf;
+
+ var class2type = {};
+
+ var toString = class2type.toString;
+
+ var hasOwn = class2type.hasOwnProperty;
+
+ var fnToString = hasOwn.toString;
+
+ var ObjectFunctionString = fnToString.call( Object );
+
+ var support = {};
+
+ var isFunction = function isFunction( obj ) {
+
+ // Support: Chrome <=57, Firefox <=52
+ // In some browsers, typeof returns "function" for HTML