diff --git a/dist/amd/can-util.js b/dist/amd/can-util.js
new file mode 100644
index 00000000..86785c96
--- /dev/null
+++ b/dist/amd/can-util.js
@@ -0,0 +1,10 @@
+/*can-util@3.3.3#can-util*/
+define(function (require, exports, module) {
+ var deepAssign = require('./js/deep-assign/deep-assign');
+ var omit = require('./js/omit/omit');
+ var namespace = require('can-namespace');
+ module.exports = deepAssign(namespace, require('./dom/dom'), omit(require('./js/js'), [
+ 'cid',
+ 'types'
+ ]));
+});
\ No newline at end of file
diff --git a/dist/amd/dom/ajax/ajax.js b/dist/amd/dom/ajax/ajax.js
new file mode 100644
index 00000000..5c72aa95
--- /dev/null
+++ b/dist/amd/dom/ajax/ajax.js
@@ -0,0 +1,145 @@
+/*can-util@3.3.3#dom/ajax/ajax*/
+define(function (require, exports, module) {
+ (function (global) {
+ var Global = require('../../js/global/global');
+ var assign = require('../../js/assign/assign');
+ var namespace = require('can-namespace');
+ var parseURI = require('../../js/parse-uri/parse-uri');
+ var param = require('../../js/param/param');
+ var xhrs = [
+ function () {
+ return new XMLHttpRequest();
+ },
+ function () {
+ return new ActiveXObject('Microsoft.XMLHTTP');
+ },
+ function () {
+ return new ActiveXObject('MSXML2.XMLHTTP.3.0');
+ },
+ function () {
+ return new ActiveXObject('MSXML2.XMLHTTP');
+ }
+ ], _xhrf = null;
+ var originUrl = parseURI(Global().location.href);
+ var makeXhr = function () {
+ if (_xhrf != null) {
+ return _xhrf();
+ }
+ for (var i = 0, l = xhrs.length; i < l; i++) {
+ try {
+ var f = xhrs[i], req = f();
+ if (req != null) {
+ _xhrf = f;
+ return req;
+ }
+ } catch (e) {
+ continue;
+ }
+ }
+ return function () {
+ };
+ };
+ var _xhrResp = function (xhr, options) {
+ switch (options.dataType || xhr.getResponseHeader('Content-Type').split(';')[0]) {
+ case 'text/xml':
+ case 'xml':
+ return xhr.responseXML;
+ case 'text/json':
+ case 'application/json':
+ case 'text/javascript':
+ case 'application/javascript':
+ case 'application/x-javascript':
+ case 'json':
+ return JSON.parse(xhr.responseText);
+ default:
+ return xhr.responseText;
+ }
+ };
+ module.exports = namespace.ajax = function (o) {
+ var xhr = makeXhr(), timer, n = 0;
+ var deferred = {};
+ var promise = new Promise(function (resolve, reject) {
+ deferred.resolve = resolve;
+ deferred.reject = reject;
+ });
+ var requestUrl;
+ promise.abort = function () {
+ xhr.abort();
+ };
+ o = assign({
+ userAgent: 'XMLHttpRequest',
+ lang: 'en',
+ type: 'GET',
+ data: null,
+ dataType: 'json'
+ }, o);
+ if (o.crossDomain == null) {
+ try {
+ requestUrl = parseURI(o.url);
+ o.crossDomain = !!(requestUrl.protocol && requestUrl.protocol !== originUrl.protocol || requestUrl.host && requestUrl.host !== originUrl.host);
+ } catch (e) {
+ o.crossDomain = true;
+ }
+ }
+ if (o.timeout) {
+ timer = setTimeout(function () {
+ xhr.abort();
+ if (o.timeoutFn) {
+ o.timeoutFn(o.url);
+ }
+ }, o.timeout);
+ }
+ xhr.onreadystatechange = function () {
+ try {
+ if (xhr.readyState === 4) {
+ if (timer) {
+ clearTimeout(timer);
+ }
+ if (xhr.status < 300) {
+ if (o.success) {
+ o.success(_xhrResp(xhr, o));
+ }
+ } else if (o.error) {
+ o.error(xhr, xhr.status, xhr.statusText);
+ }
+ if (o.complete) {
+ o.complete(xhr, xhr.statusText);
+ }
+ if (xhr.status >= 200 && xhr.status < 300) {
+ deferred.resolve(_xhrResp(xhr, o));
+ } else {
+ deferred.reject(xhr);
+ }
+ } else if (o.progress) {
+ o.progress(++n);
+ }
+ } catch (e) {
+ deferred.reject(e);
+ }
+ };
+ var url = o.url, data = null, type = o.type.toUpperCase();
+ var isPost = type === 'POST' || type === 'PUT';
+ if (!isPost && o.data) {
+ url += '?' + param(o.data);
+ }
+ xhr.open(type, url);
+ var isSimpleCors = o.crossDomain && [
+ 'GET',
+ 'POST',
+ 'HEAD'
+ ].indexOf(type) !== -1;
+ if (isPost) {
+ var isJson = o.dataType.indexOf('json') >= 0;
+ data = isJson && !isSimpleCors ? typeof o.data === 'object' ? JSON.stringify(o.data) : o.data : param(o.data);
+ xhr.setRequestHeader('Content-Type', isJson && !isSimpleCors ? 'application/json' : 'application/x-www-form-urlencoded');
+ }
+ if (!isSimpleCors) {
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ }
+ xhr.send(data);
+ return promise;
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/dom/attr/attr.js b/dist/amd/dom/attr/attr.js
new file mode 100644
index 00000000..28387f9a
--- /dev/null
+++ b/dist/amd/dom/attr/attr.js
@@ -0,0 +1,542 @@
+/*can-util@3.3.3#dom/attr/attr*/
+define(function (require, exports, module) {
+ (function (global) {
+ var setImmediate = require('../../js/set-immediate/set-immediate');
+ var getDocument = require('../document/document');
+ var global = require('../../js/global/global')();
+ var isOfGlobalDocument = require('../is-of-global-document/is-of-global-document');
+ var setData = require('../data/data');
+ var domContains = require('../contains/contains');
+ var domEvents = require('../events/events');
+ var domDispatch = require('../dispatch/dispatch');
+ var MUTATION_OBSERVER = require('../mutation-observer/mutation-observer');
+ var each = require('../../js/each/each');
+ var types = require('can-types');
+ var diff = require('../../js/diff/diff');
+ require('../events/attributes/attributes');
+ var namespaces = { 'xlink': 'http://www.w3.org/1999/xlink' };
+ var formElements = {
+ 'INPUT': true,
+ 'TEXTAREA': true,
+ 'SELECT': true
+ }, toString = function (value) {
+ if (value == null) {
+ return '';
+ } else {
+ return '' + value;
+ }
+ }, isSVG = function (el) {
+ return el.namespaceURI === 'http://www.w3.org/2000/svg';
+ }, truthy = function () {
+ return true;
+ }, getSpecialTest = function (special) {
+ return special && special.test || truthy;
+ }, propProp = function (prop, obj) {
+ obj = obj || {};
+ obj.get = function () {
+ return this[prop];
+ };
+ obj.set = function (value) {
+ if (this[prop] !== value) {
+ this[prop] = value;
+ }
+ return value;
+ };
+ return obj;
+ }, booleanProp = function (prop) {
+ return {
+ isBoolean: true,
+ set: function (value) {
+ if (prop in this) {
+ this[prop] = value !== false;
+ } else {
+ this.setAttribute(prop, '');
+ }
+ },
+ remove: function () {
+ this[prop] = false;
+ }
+ };
+ }, setupMO = function (el, callback) {
+ var attrMO = setData.get.call(el, 'attrMO');
+ if (!attrMO) {
+ var onMutation = function () {
+ callback.call(el);
+ };
+ var MO = MUTATION_OBSERVER();
+ if (MO) {
+ var observer = new MO(onMutation);
+ observer.observe(el, {
+ childList: true,
+ subtree: true
+ });
+ setData.set.call(el, 'attrMO', observer);
+ } else {
+ setData.set.call(el, 'attrMO', true);
+ setData.set.call(el, 'canBindingCallback', { onMutation: onMutation });
+ }
+ }
+ }, setChildOptions = function (el, value) {
+ if (value != null) {
+ var child = el.firstChild, hasSelected = false;
+ while (child) {
+ if (child.nodeName === 'OPTION') {
+ if (value === child.value) {
+ hasSelected = child.selected = true;
+ break;
+ }
+ }
+ child = child.nextSibling;
+ }
+ if (!hasSelected) {
+ el.selectedIndex = -1;
+ }
+ } else {
+ el.selectedIndex = -1;
+ }
+ }, setChildOptionsOnChange = function (select, aEL) {
+ var handler = setData.get.call(select, 'attrSetChildOptions');
+ if (handler) {
+ return Function.prototype;
+ }
+ handler = function () {
+ setChildOptions(select, select.value);
+ };
+ setData.set.call(select, 'attrSetChildOptions', handler);
+ aEL.call(select, 'change', handler);
+ return function (rEL) {
+ setData.clean.call(select, 'attrSetChildOptions');
+ rEL.call(select, 'change', handler);
+ };
+ }, attr = {
+ special: {
+ checked: {
+ get: function () {
+ return this.checked;
+ },
+ set: function (val) {
+ var notFalse = !!val || val === '' || arguments.length === 0;
+ this.checked = notFalse;
+ if (notFalse && this.type === 'radio') {
+ this.defaultChecked = true;
+ }
+ return val;
+ },
+ remove: function () {
+ this.checked = false;
+ },
+ test: function () {
+ return this.nodeName === 'INPUT';
+ }
+ },
+ 'class': {
+ get: function () {
+ if (isSVG(this)) {
+ return this.getAttribute('class');
+ }
+ return this.className;
+ },
+ set: function (val) {
+ val = val || '';
+ if (isSVG(this)) {
+ this.setAttribute('class', '' + val);
+ } else {
+ this.className = val;
+ }
+ return val;
+ }
+ },
+ disabled: booleanProp('disabled'),
+ focused: {
+ get: function () {
+ return this === document.activeElement;
+ },
+ set: function (val) {
+ var cur = attr.get(this, 'focused');
+ if (cur !== val) {
+ var element = this;
+ types.queueTask([
+ function () {
+ if (val) {
+ element.focus();
+ } else {
+ element.blur();
+ }
+ },
+ this,
+ []
+ ]);
+ }
+ return !!val;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ aEL.call(this, 'focus', handler);
+ aEL.call(this, 'blur', handler);
+ return function (rEL) {
+ rEL.call(this, 'focus', handler);
+ rEL.call(this, 'blur', handler);
+ };
+ },
+ test: function () {
+ return this.nodeName === 'INPUT';
+ }
+ },
+ 'for': propProp('htmlFor'),
+ innertext: propProp('innerText'),
+ innerhtml: propProp('innerHTML'),
+ innerHTML: propProp('innerHTML', {
+ addEventListener: function (eventName, handler, aEL) {
+ var handlers = [];
+ var el = this;
+ each([
+ 'change',
+ 'blur'
+ ], function (eventName) {
+ var localHandler = function () {
+ handler.apply(this, arguments);
+ };
+ domEvents.addEventListener.call(el, eventName, localHandler);
+ handlers.push([
+ eventName,
+ localHandler
+ ]);
+ });
+ return function (rEL) {
+ each(handlers, function (info) {
+ rEL.call(el, info[0], info[1]);
+ });
+ };
+ }
+ }),
+ required: booleanProp('required'),
+ readonly: booleanProp('readOnly'),
+ selected: {
+ get: function () {
+ return this.selected;
+ },
+ set: function (val) {
+ val = !!val;
+ setData.set.call(this, 'lastSetValue', val);
+ return this.selected = val;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ var option = this;
+ var select = this.parentNode;
+ var lastVal = option.selected;
+ var localHandler = function (changeEvent) {
+ var curVal = option.selected;
+ lastVal = setData.get.call(option, 'lastSetValue') || lastVal;
+ if (curVal !== lastVal) {
+ lastVal = curVal;
+ domDispatch.call(option, eventName);
+ }
+ };
+ var removeChangeHandler = setChildOptionsOnChange(select, aEL);
+ domEvents.addEventListener.call(select, 'change', localHandler);
+ aEL.call(option, eventName, handler);
+ return function (rEL) {
+ removeChangeHandler(rEL);
+ domEvents.removeEventListener.call(select, 'change', localHandler);
+ rEL.call(option, eventName, handler);
+ };
+ },
+ test: function () {
+ return this.nodeName === 'OPTION' && this.parentNode && this.parentNode.nodeName === 'SELECT';
+ }
+ },
+ src: {
+ set: function (val) {
+ if (val == null || val === '') {
+ this.removeAttribute('src');
+ return null;
+ } else {
+ this.setAttribute('src', val);
+ return val;
+ }
+ }
+ },
+ style: {
+ set: function () {
+ var el = global.document && getDocument().createElement('div');
+ if (el && el.style && 'cssText' in el.style) {
+ return function (val) {
+ return this.style.cssText = val || '';
+ };
+ } else {
+ return function (val) {
+ return this.setAttribute('style', val);
+ };
+ }
+ }()
+ },
+ textcontent: propProp('textContent'),
+ value: {
+ get: function () {
+ var value = this.value;
+ if (this.nodeName === 'SELECT') {
+ if ('selectedIndex' in this && this.selectedIndex === -1) {
+ value = undefined;
+ }
+ }
+ return value;
+ },
+ set: function (value) {
+ var nodeName = this.nodeName.toLowerCase();
+ if (nodeName === 'input') {
+ value = toString(value);
+ }
+ if (this.value !== value || nodeName === 'option') {
+ this.value = value;
+ }
+ if (attr.defaultValue[nodeName]) {
+ this.defaultValue = value;
+ }
+ if (nodeName === 'select') {
+ setData.set.call(this, 'attrValueLastVal', value);
+ setChildOptions(this, value === null ? value : this.value);
+ var docEl = this.ownerDocument.documentElement;
+ if (!domContains.call(docEl, this)) {
+ var select = this;
+ var initialSetHandler = function () {
+ domEvents.removeEventListener.call(select, 'inserted', initialSetHandler);
+ setChildOptions(select, value === null ? value : select.value);
+ };
+ domEvents.addEventListener.call(this, 'inserted', initialSetHandler);
+ }
+ setupMO(this, function () {
+ var value = setData.get.call(this, 'attrValueLastVal');
+ attr.set(this, 'value', value);
+ domDispatch.call(this, 'change');
+ });
+ }
+ return value;
+ },
+ test: function () {
+ return formElements[this.nodeName];
+ }
+ },
+ values: {
+ get: function () {
+ var values = [];
+ var child = this.firstChild;
+ while (child) {
+ if (child.nodeName === 'OPTION' && child.selected) {
+ values.push(child.value);
+ }
+ child = child.nextSibling;
+ }
+ return values;
+ },
+ set: function (values) {
+ values = values || [];
+ var child = this.firstChild;
+ while (child) {
+ if (child.nodeName === 'OPTION') {
+ child.selected = values.indexOf(child.value) !== -1;
+ }
+ child = child.nextSibling;
+ }
+ setData.set.call(this, 'stickyValues', attr.get(this, 'values'));
+ setupMO(this, function () {
+ var previousValues = setData.get.call(this, 'stickyValues');
+ attr.set(this, 'values', previousValues);
+ var currentValues = setData.get.call(this, 'stickyValues');
+ var changes = diff(previousValues.slice().sort(), currentValues.slice().sort());
+ if (changes.length) {
+ domDispatch.call(this, 'values');
+ }
+ });
+ return values;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ var localHandler = function () {
+ domDispatch.call(this, 'values');
+ };
+ domEvents.addEventListener.call(this, 'change', localHandler);
+ aEL.call(this, eventName, handler);
+ return function (rEL) {
+ domEvents.removeEventListener.call(this, 'change', localHandler);
+ rEL.call(this, eventName, handler);
+ };
+ }
+ }
+ },
+ defaultValue: {
+ input: true,
+ textarea: true
+ },
+ setAttrOrProp: function (el, attrName, val) {
+ attrName = attrName.toLowerCase();
+ var special = attr.special[attrName];
+ if (special && special.isBoolean && !val) {
+ this.remove(el, attrName);
+ } else {
+ this.set(el, attrName, val);
+ }
+ },
+ set: function (el, attrName, val) {
+ var usingMutationObserver = isOfGlobalDocument(el) && MUTATION_OBSERVER();
+ attrName = attrName.toLowerCase();
+ var oldValue;
+ if (!usingMutationObserver) {
+ oldValue = attr.get(el, attrName);
+ }
+ var newValue;
+ var special = attr.special[attrName];
+ var setter = special && special.set;
+ var test = getSpecialTest(special);
+ if (typeof setter === 'function' && test.call(el)) {
+ if (arguments.length === 2) {
+ newValue = setter.call(el);
+ } else {
+ newValue = setter.call(el, val);
+ }
+ } else {
+ attr.setAttribute(el, attrName, val);
+ }
+ if (!usingMutationObserver && newValue !== oldValue) {
+ attr.trigger(el, attrName, oldValue);
+ }
+ },
+ setSelectValue: function (el, value) {
+ attr.set(el, 'value', value);
+ },
+ setAttribute: function () {
+ var doc = getDocument();
+ if (doc && document.createAttribute) {
+ try {
+ doc.createAttribute('{}');
+ } catch (e) {
+ var invalidNodes = {}, attributeDummy = document.createElement('div');
+ return function (el, attrName, val) {
+ var first = attrName.charAt(0), cachedNode, node, attr;
+ if ((first === '{' || first === '(' || first === '*') && el.setAttributeNode) {
+ cachedNode = invalidNodes[attrName];
+ if (!cachedNode) {
+ attributeDummy.innerHTML = '
';
+ cachedNode = invalidNodes[attrName] = attributeDummy.childNodes[0].attributes[0];
+ }
+ node = cachedNode.cloneNode();
+ node.value = val;
+ el.setAttributeNode(node);
+ } else {
+ attr = attrName.split(':');
+ if (attr.length !== 1) {
+ el.setAttributeNS(namespaces[attr[0]], attrName, val);
+ } else {
+ el.setAttribute(attrName, val);
+ }
+ }
+ };
+ }
+ }
+ return function (el, attrName, val) {
+ el.setAttribute(attrName, val);
+ };
+ }(),
+ trigger: function (el, attrName, oldValue) {
+ if (setData.get.call(el, 'canHasAttributesBindings')) {
+ attrName = attrName.toLowerCase();
+ return setImmediate(function () {
+ domDispatch.call(el, {
+ type: 'attributes',
+ attributeName: attrName,
+ target: el,
+ oldValue: oldValue,
+ bubbles: false
+ }, []);
+ });
+ }
+ },
+ get: function (el, attrName) {
+ attrName = attrName.toLowerCase();
+ var special = attr.special[attrName];
+ var getter = special && special.get;
+ var test = getSpecialTest(special);
+ if (typeof getter === 'function' && test.call(el)) {
+ return getter.call(el);
+ } else {
+ return el.getAttribute(attrName);
+ }
+ },
+ remove: function (el, attrName) {
+ attrName = attrName.toLowerCase();
+ var oldValue;
+ if (!MUTATION_OBSERVER()) {
+ oldValue = attr.get(el, attrName);
+ }
+ var special = attr.special[attrName];
+ var setter = special && special.set;
+ var remover = special && special.remove;
+ var test = getSpecialTest(special);
+ if (typeof remover === 'function' && test.call(el)) {
+ remover.call(el);
+ } else if (typeof setter === 'function' && test.call(el)) {
+ setter.call(el, undefined);
+ } else {
+ el.removeAttribute(attrName);
+ }
+ if (!MUTATION_OBSERVER() && oldValue != null) {
+ attr.trigger(el, attrName, oldValue);
+ }
+ },
+ has: function () {
+ var el = getDocument() && document.createElement('div');
+ if (el && el.hasAttribute) {
+ return function (el, name) {
+ return el.hasAttribute(name);
+ };
+ } else {
+ return function (el, name) {
+ return el.getAttribute(name) !== null;
+ };
+ }
+ }()
+ };
+ var oldAddEventListener = domEvents.addEventListener;
+ domEvents.addEventListener = function (eventName, handler) {
+ var special = attr.special[eventName];
+ if (special && special.addEventListener) {
+ var teardown = special.addEventListener.call(this, eventName, handler, oldAddEventListener);
+ var teardowns = setData.get.call(this, 'attrTeardowns');
+ if (!teardowns) {
+ setData.set.call(this, 'attrTeardowns', teardowns = {});
+ }
+ if (!teardowns[eventName]) {
+ teardowns[eventName] = [];
+ }
+ teardowns[eventName].push({
+ teardown: teardown,
+ handler: handler
+ });
+ return;
+ }
+ return oldAddEventListener.apply(this, arguments);
+ };
+ var oldRemoveEventListener = domEvents.removeEventListener;
+ domEvents.removeEventListener = function (eventName, handler) {
+ var special = attr.special[eventName];
+ if (special && special.addEventListener) {
+ var teardowns = setData.get.call(this, 'attrTeardowns');
+ if (teardowns && teardowns[eventName]) {
+ var eventTeardowns = teardowns[eventName];
+ for (var i = 0, len = eventTeardowns.length; i < len; i++) {
+ if (eventTeardowns[i].handler === handler) {
+ eventTeardowns[i].teardown.call(this, oldRemoveEventListener);
+ eventTeardowns.splice(i, 1);
+ break;
+ }
+ }
+ if (eventTeardowns.length === 0) {
+ delete teardowns[eventName];
+ }
+ }
+ return;
+ }
+ return oldRemoveEventListener.apply(this, arguments);
+ };
+ module.exports = exports = attr;
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/dom/child-nodes/child-nodes.js b/dist/amd/dom/child-nodes/child-nodes.js
new file mode 100644
index 00000000..b06b5124
--- /dev/null
+++ b/dist/amd/dom/child-nodes/child-nodes.js
@@ -0,0 +1,18 @@
+/*can-util@3.3.3#dom/child-nodes/child-nodes*/
+define(function (require, exports, module) {
+ function childNodes(node) {
+ var childNodes = node.childNodes;
+ if ('length' in childNodes) {
+ return childNodes;
+ } else {
+ var cur = node.firstChild;
+ var nodes = [];
+ while (cur) {
+ nodes.push(cur);
+ cur = cur.nextSibling;
+ }
+ return nodes;
+ }
+ }
+ module.exports = childNodes;
+});
\ No newline at end of file
diff --git a/dist/amd/dom/class-name/class-name.js b/dist/amd/dom/class-name/class-name.js
new file mode 100644
index 00000000..9f91abaa
--- /dev/null
+++ b/dist/amd/dom/class-name/class-name.js
@@ -0,0 +1,28 @@
+/*can-util@3.3.3#dom/class-name/class-name*/
+define(function (require, exports, module) {
+ var has = function (className) {
+ if (this.classList) {
+ return this.classList.contains(className);
+ } else {
+ return !!this.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
+ }
+ };
+ module.exports = {
+ has: has,
+ add: function (className) {
+ if (this.classList) {
+ this.classList.add(className);
+ } else if (!has.call(this, className)) {
+ this.className += ' ' + className;
+ }
+ },
+ remove: function (className) {
+ if (this.classList) {
+ this.classList.remove(className);
+ } else if (has.call(this, className)) {
+ var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
+ this.className = this.className.replace(reg, ' ');
+ }
+ }
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/contains/contains.js b/dist/amd/dom/contains/contains.js
new file mode 100644
index 00000000..aa04adfe
--- /dev/null
+++ b/dist/amd/dom/contains/contains.js
@@ -0,0 +1,6 @@
+/*can-util@3.3.3#dom/contains/contains*/
+define(function (require, exports, module) {
+ module.exports = function (child) {
+ return this.contains(child);
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/data/core.js b/dist/amd/dom/data/core.js
new file mode 100644
index 00000000..30e6dbb3
--- /dev/null
+++ b/dist/amd/dom/data/core.js
@@ -0,0 +1,53 @@
+/*can-util@3.3.3#dom/data/core*/
+define(function (require, exports, module) {
+ var isEmptyObject = require('../../js/is-empty-object/is-empty-object');
+ var data = {};
+ var expando = 'can' + new Date();
+ var uuid = 0;
+ var setData = function (name, value) {
+ var id = this[expando] || (this[expando] = ++uuid), store = data[id], newStore = false;
+ if (!data[id]) {
+ newStore = true;
+ store = data[id] = {};
+ }
+ if (name !== undefined) {
+ store[name] = value;
+ }
+ return newStore;
+ };
+ var deleteNode = function () {
+ var id = this[expando];
+ var nodeDeleted = false;
+ if (id && data[id]) {
+ nodeDeleted = true;
+ delete data[id];
+ }
+ return nodeDeleted;
+ };
+ module.exports = {
+ _data: data,
+ getCid: function () {
+ return this[expando];
+ },
+ cid: function () {
+ return this[expando] || (this[expando] = ++uuid);
+ },
+ expando: expando,
+ get: function (key) {
+ var id = this[expando], store = id && data[id];
+ return key === undefined ? store || setData(this) : store && store[key];
+ },
+ set: setData,
+ clean: function (prop) {
+ var id = this[expando];
+ var itemData = data[id];
+ if (itemData && itemData[prop]) {
+ delete itemData[prop];
+ }
+ if (isEmptyObject(itemData)) {
+ deleteNode.call(this);
+ }
+ },
+ delete: deleteNode
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/data/data.js b/dist/amd/dom/data/data.js
new file mode 100644
index 00000000..d0d12b02
--- /dev/null
+++ b/dist/amd/dom/data/data.js
@@ -0,0 +1,29 @@
+/*can-util@3.3.3#dom/data/data*/
+define(function (require, exports, module) {
+ var domDataCore = require('./core');
+ var mutationDocument = require('../mutation-observer/document/document');
+ var deleteNode = function () {
+ return domDataCore.delete.call(this);
+ };
+ var elementSetCount = 0;
+ var cleanupDomData = function (node) {
+ elementSetCount -= deleteNode.call(node) ? 1 : 0;
+ if (elementSetCount === 0) {
+ mutationDocument.offAfterRemovedNodes(cleanupDomData);
+ }
+ };
+ module.exports = {
+ getCid: domDataCore.getCid,
+ cid: domDataCore.cid,
+ expando: domDataCore.expando,
+ clean: domDataCore.clean,
+ get: domDataCore.get,
+ set: function (name, value) {
+ if (elementSetCount === 0) {
+ mutationDocument.onAfterRemovedNodes(cleanupDomData);
+ }
+ elementSetCount += domDataCore.set.call(this, name, value) ? 1 : 0;
+ },
+ delete: deleteNode
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/dispatch/dispatch.js b/dist/amd/dom/dispatch/dispatch.js
new file mode 100644
index 00000000..2684e028
--- /dev/null
+++ b/dist/amd/dom/dispatch/dispatch.js
@@ -0,0 +1,7 @@
+/*can-util@3.3.3#dom/dispatch/dispatch*/
+define(function (require, exports, module) {
+ var domEvents = require('../events/events');
+ module.exports = function () {
+ return domEvents.dispatch.apply(this, arguments);
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/document/document.js b/dist/amd/dom/document/document.js
new file mode 100644
index 00000000..4381f275
--- /dev/null
+++ b/dist/amd/dom/document/document.js
@@ -0,0 +1,15 @@
+/*can-util@3.3.3#dom/document/document*/
+define(function (require, exports, module) {
+ (function (global) {
+ var global = require('../../js/global/global');
+ var setDocument;
+ module.exports = function (setDoc) {
+ if (setDoc) {
+ setDocument = setDoc;
+ }
+ return setDocument || global().document;
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/dom/dom.js b/dist/amd/dom/dom.js
new file mode 100644
index 00000000..ecec3d21
--- /dev/null
+++ b/dist/amd/dom/dom.js
@@ -0,0 +1,24 @@
+/*can-util@3.3.3#dom/dom*/
+define(function (require, exports, module) {
+ (function (global) {
+ module.exports = {
+ ajax: require('./ajax/ajax'),
+ attr: require('./attr/attr'),
+ childNodes: require('./child-nodes/child-nodes'),
+ className: require('./class-name/class-name'),
+ contains: require('./contains/contains'),
+ data: require('./data/data'),
+ dispatch: require('./dispatch/dispatch'),
+ document: require('./document/document'),
+ events: require('./events/events'),
+ frag: require('./frag/frag'),
+ fragment: require('./fragment/fragment'),
+ isOfGlobalDocument: require('./is-of-global-document/is-of-global-document'),
+ matches: require('./matches/matches'),
+ mutate: require('./mutate/mutate'),
+ mutationObserver: require('./mutation-observer/mutation-observer')
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/dom/events/attributes/attributes.js b/dist/amd/dom/events/attributes/attributes.js
new file mode 100644
index 00000000..a6b49c30
--- /dev/null
+++ b/dist/amd/dom/events/attributes/attributes.js
@@ -0,0 +1,52 @@
+/*can-util@3.3.3#dom/events/attributes/attributes*/
+define(function (require, exports, module) {
+ (function (global) {
+ var events = require('../events');
+ var isOfGlobalDocument = require('../../is-of-global-document/is-of-global-document');
+ var domData = require('../../data/data');
+ var getMutationObserver = require('../../mutation-observer/mutation-observer');
+ var assign = require('../../../js/assign/assign');
+ var domDispatch = require('../../dispatch/dispatch');
+ var originalAdd = events.addEventListener, originalRemove = events.removeEventListener;
+ events.addEventListener = function (eventName) {
+ if (eventName === 'attributes') {
+ var MutationObserver = getMutationObserver();
+ if (isOfGlobalDocument(this) && MutationObserver) {
+ var self = this;
+ var observer = new MutationObserver(function (mutations) {
+ mutations.forEach(function (mutation) {
+ var copy = assign({}, mutation);
+ domDispatch.call(self, copy, [], false);
+ });
+ });
+ observer.observe(this, {
+ attributes: true,
+ attributeOldValue: true
+ });
+ domData.set.call(this, 'canAttributesObserver', observer);
+ } else {
+ domData.set.call(this, 'canHasAttributesBindings', true);
+ }
+ }
+ return originalAdd.apply(this, arguments);
+ };
+ events.removeEventListener = function (eventName) {
+ if (eventName === 'attributes') {
+ var MutationObserver = getMutationObserver();
+ var observer;
+ if (isOfGlobalDocument(this) && MutationObserver) {
+ observer = domData.get.call(this, 'canAttributesObserver');
+ if (observer && observer.disconnect) {
+ observer.disconnect();
+ domData.clean.call(this, 'canAttributesObserver');
+ }
+ } else {
+ domData.clean.call(this, 'canHasAttributesBindings');
+ }
+ }
+ return originalRemove.apply(this, arguments);
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/dom/events/events.js b/dist/amd/dom/events/events.js
new file mode 100644
index 00000000..2091eebc
--- /dev/null
+++ b/dist/amd/dom/events/events.js
@@ -0,0 +1,59 @@
+/*can-util@3.3.3#dom/events/events*/
+define(function (require, exports, module) {
+ var assign = require('../../js/assign/assign');
+ var _document = require('../document/document');
+ var isPlainObject = require('../../js/is-plain-object/is-plain-object');
+ var fixSyntheticEventsOnDisabled = false;
+ function isDispatchingOnDisabled(element, ev) {
+ var isInsertedOrRemoved = isPlainObject(ev) ? ev.type === 'inserted' || ev.type === 'removed' : ev === 'inserted' || ev === 'removed';
+ var isDisabled = !!element.disabled;
+ return isInsertedOrRemoved && isDisabled;
+ }
+ module.exports = {
+ addEventListener: function () {
+ this.addEventListener.apply(this, arguments);
+ },
+ removeEventListener: function () {
+ this.removeEventListener.apply(this, arguments);
+ },
+ canAddEventListener: function () {
+ return this.nodeName && (this.nodeType === 1 || this.nodeType === 9) || this === window;
+ },
+ dispatch: function (event, args, bubbles) {
+ var doc = _document();
+ var ret;
+ var dispatchingOnDisabled = fixSyntheticEventsOnDisabled && isDispatchingOnDisabled(this, event);
+ var ev = doc.createEvent('HTMLEvents');
+ var isString = typeof event === 'string';
+ ev.initEvent(isString ? event : event.type, bubbles === undefined ? true : bubbles, false);
+ if (!isString) {
+ assign(ev, event);
+ }
+ ev.args = args;
+ if (dispatchingOnDisabled) {
+ this.disabled = false;
+ }
+ ret = this.dispatchEvent(ev);
+ if (dispatchingOnDisabled) {
+ this.disabled = true;
+ }
+ return ret;
+ }
+ };
+ (function () {
+ var input = document.createElement('input');
+ input.disabled = true;
+ var timer = setTimeout(function () {
+ fixSyntheticEventsOnDisabled = true;
+ }, 50);
+ module.exports.addEventListener.call(input, 'foo', function () {
+ clearTimeout(timer);
+ });
+ try {
+ module.exports.dispatch.call(input, 'foo', [], false);
+ } catch (e) {
+ clearTimeout(timer);
+ fixSyntheticEventsOnDisabled = true;
+ }
+ }());
+});
\ No newline at end of file
diff --git a/dist/amd/dom/frag/frag.js b/dist/amd/dom/frag/frag.js
new file mode 100644
index 00000000..77663623
--- /dev/null
+++ b/dist/amd/dom/frag/frag.js
@@ -0,0 +1,40 @@
+/*can-util@3.3.3#dom/frag/frag*/
+define(function (require, exports, module) {
+ var getDocument = require('../document/document');
+ var fragment = require('../fragment/fragment');
+ var each = require('../../js/each/each');
+ var childNodes = require('../child-nodes/child-nodes');
+ var makeFrag = function (item, doc) {
+ var document = doc || getDocument();
+ var frag;
+ if (!item || typeof item === 'string') {
+ frag = fragment(item == null ? '' : '' + item, document);
+ if (!frag.childNodes.length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ } else if (item.nodeType === 11) {
+ return item;
+ } else if (typeof item.nodeType === 'number') {
+ frag = document.createDocumentFragment();
+ frag.appendChild(item);
+ return frag;
+ } else if (typeof item.length === 'number') {
+ frag = document.createDocumentFragment();
+ each(item, function (item) {
+ frag.appendChild(makeFrag(item));
+ });
+ if (!childNodes(frag).length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ } else {
+ frag = fragment('' + item, document);
+ if (!childNodes(frag).length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ }
+ };
+ module.exports = makeFrag;
+});
\ No newline at end of file
diff --git a/dist/amd/dom/fragment/fragment.js b/dist/amd/dom/fragment/fragment.js
new file mode 100644
index 00000000..eabecb73
--- /dev/null
+++ b/dist/amd/dom/fragment/fragment.js
@@ -0,0 +1,53 @@
+/*can-util@3.3.3#dom/fragment/fragment*/
+define(function (require, exports, module) {
+ var getDocument = require('../document/document'), childNodes = require('../child-nodes/child-nodes');
+ var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name, doc) {
+ if (name === undefined) {
+ name = fragmentRE.test(html) && RegExp.$1;
+ }
+ if (html && toString.call(html.replace) === '[object Function]') {
+ html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>$2>');
+ }
+ var container = doc.createElement('div'), temp = doc.createElement('div');
+ if (name === 'tbody' || name === 'tfoot' || name === 'thead' || name === 'colgroup') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild;
+ } else if (name === 'col') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild;
+ } else if (name === 'tr') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild;
+ } else if (name === 'td' || name === 'th') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild;
+ } else if (name === 'option') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild;
+ } else {
+ container.innerHTML = '' + html;
+ }
+ var tmp = {}, children = childNodes(container);
+ tmp.length = children.length;
+ for (var i = 0; i < children.length; i++) {
+ tmp[i] = children[i];
+ }
+ return [].slice.call(tmp);
+ };
+ var buildFragment = function (html, doc) {
+ if (html && html.nodeType === 11) {
+ return html;
+ }
+ if (!doc) {
+ doc = getDocument();
+ } else if (doc.length) {
+ doc = doc[0];
+ }
+ var parts = fragment(html, undefined, doc), frag = (doc || document).createDocumentFragment();
+ for (var i = 0, length = parts.length; i < length; i++) {
+ frag.appendChild(parts[i]);
+ }
+ return frag;
+ };
+ module.exports = buildFragment;
+});
\ No newline at end of file
diff --git a/dist/amd/dom/is-of-global-document/is-of-global-document.js b/dist/amd/dom/is-of-global-document/is-of-global-document.js
new file mode 100644
index 00000000..d7050e44
--- /dev/null
+++ b/dist/amd/dom/is-of-global-document/is-of-global-document.js
@@ -0,0 +1,7 @@
+/*can-util@3.3.3#dom/is-of-global-document/is-of-global-document*/
+define(function (require, exports, module) {
+ var getDocument = require('../document/document');
+ module.exports = function (el) {
+ return (el.ownerDocument || el) === getDocument();
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/matches/matches.js b/dist/amd/dom/matches/matches.js
new file mode 100644
index 00000000..f47f9f85
--- /dev/null
+++ b/dist/amd/dom/matches/matches.js
@@ -0,0 +1,10 @@
+/*can-util@3.3.3#dom/matches/matches*/
+define(function (require, exports, module) {
+ var matchesMethod = function (element) {
+ return element.matches || element.webkitMatchesSelector || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || element.oMatchesSelector;
+ };
+ module.exports = function () {
+ var method = matchesMethod(this);
+ return method ? method.apply(this, arguments) : false;
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/mutate/mutate.js b/dist/amd/dom/mutate/mutate.js
new file mode 100644
index 00000000..c4744f9a
--- /dev/null
+++ b/dist/amd/dom/mutate/mutate.js
@@ -0,0 +1,138 @@
+/*can-util@3.3.3#dom/mutate/mutate*/
+define(function (require, exports, module) {
+ var makeArray = require('../../js/make-array/make-array');
+ var setImmediate = require('../../js/set-immediate/set-immediate');
+ var CID = require('can-cid');
+ var getMutationObserver = require('../mutation-observer/mutation-observer');
+ var childNodes = require('../child-nodes/child-nodes');
+ var domContains = require('../contains/contains');
+ var domDispatch = require('../dispatch/dispatch');
+ var DOCUMENT = require('../document/document');
+ var domData = require('../data/data');
+ var mutatedElements;
+ var checks = {
+ inserted: function (root, elem) {
+ return domContains.call(root, elem);
+ },
+ removed: function (root, elem) {
+ return !domContains.call(root, elem);
+ }
+ };
+ var fireOn = function (elems, root, check, event, dispatched) {
+ if (!elems.length) {
+ return;
+ }
+ var children, cid;
+ for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) {
+ cid = CID(elem);
+ if (elem.getElementsByTagName && check(root, elem) && !dispatched[cid]) {
+ dispatched[cid] = true;
+ children = makeArray(elem.getElementsByTagName('*'));
+ domDispatch.call(elem, event, [], false);
+ if (event === 'removed') {
+ domData.delete.call(elem);
+ }
+ for (var j = 0, child; (child = children[j]) !== undefined; j++) {
+ cid = CID(child);
+ if (!dispatched[cid]) {
+ domDispatch.call(child, event, [], false);
+ if (event === 'removed') {
+ domData.delete.call(child);
+ }
+ dispatched[cid] = true;
+ }
+ }
+ }
+ }
+ };
+ var fireMutations = function () {
+ var mutations = mutatedElements;
+ mutatedElements = null;
+ var firstElement = mutations[0][1][0];
+ var doc = DOCUMENT() || firstElement.ownerDocument || firstElement;
+ var root = doc.contains ? doc : doc.body;
+ var dispatched = {
+ inserted: {},
+ removed: {}
+ };
+ mutations.forEach(function (mutation) {
+ fireOn(mutation[1], root, checks[mutation[0]], mutation[0], dispatched[mutation[0]]);
+ });
+ };
+ var mutated = function (elements, type) {
+ if (!getMutationObserver() && elements.length) {
+ var firstElement = elements[0];
+ var doc = DOCUMENT() || firstElement.ownerDocument || firstElement;
+ var root = doc.contains ? doc : doc.body;
+ if (checks.inserted(root, firstElement)) {
+ if (!mutatedElements) {
+ mutatedElements = [];
+ setImmediate(fireMutations);
+ }
+ mutatedElements.push([
+ type,
+ elements
+ ]);
+ }
+ }
+ };
+ module.exports = {
+ appendChild: function (child) {
+ if (getMutationObserver()) {
+ this.appendChild(child);
+ } else {
+ var children;
+ if (child.nodeType === 11) {
+ children = makeArray(childNodes(child));
+ } else {
+ children = [child];
+ }
+ this.appendChild(child);
+ mutated(children, 'inserted');
+ }
+ },
+ insertBefore: function (child, ref, document) {
+ if (getMutationObserver()) {
+ this.insertBefore(child, ref);
+ } else {
+ var children;
+ if (child.nodeType === 11) {
+ children = makeArray(childNodes(child));
+ } else {
+ children = [child];
+ }
+ this.insertBefore(child, ref);
+ mutated(children, 'inserted');
+ }
+ },
+ removeChild: function (child) {
+ if (getMutationObserver()) {
+ this.removeChild(child);
+ } else {
+ mutated([child], 'removed');
+ this.removeChild(child);
+ }
+ },
+ replaceChild: function (newChild, oldChild) {
+ if (getMutationObserver()) {
+ this.replaceChild(newChild, oldChild);
+ } else {
+ var children;
+ if (newChild.nodeType === 11) {
+ children = makeArray(childNodes(newChild));
+ } else {
+ children = [newChild];
+ }
+ mutated([oldChild], 'removed');
+ this.replaceChild(newChild, oldChild);
+ mutated(children, 'inserted');
+ }
+ },
+ inserted: function (elements) {
+ mutated(elements, 'inserted');
+ },
+ removed: function (elements) {
+ mutated(elements, 'removed');
+ }
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/dom/mutation-observer/document/document.js b/dist/amd/dom/mutation-observer/document/document.js
new file mode 100644
index 00000000..5c681279
--- /dev/null
+++ b/dist/amd/dom/mutation-observer/document/document.js
@@ -0,0 +1,142 @@
+/*can-util@3.3.3#dom/mutation-observer/document/document*/
+define(function (require, exports, module) {
+ (function (global) {
+ var getDocument = require('../../document/document');
+ var domDataCore = require('../../data/core');
+ var MUTATION_OBSERVER = require('../mutation-observer');
+ var each = require('../../../js/each/each');
+ var CIDStore = require('../../../js/cid-set/cid-set');
+ var makeArray = require('../../../js/make-array/make-array');
+ var string = require('../../../js/string/string');
+ var dispatchIfListening = function (mutatedNode, nodes, dispatched) {
+ if (dispatched.has(mutatedNode)) {
+ return true;
+ }
+ dispatched.add(mutatedNode);
+ if (nodes.name === 'removedNodes') {
+ var documentElement = getDocument().documentElement;
+ if (documentElement.contains(mutatedNode)) {
+ return;
+ }
+ }
+ nodes.handlers.forEach(function (handler) {
+ handler(mutatedNode);
+ });
+ nodes.afterHandlers.forEach(function (handler) {
+ handler(mutatedNode);
+ });
+ };
+ var mutationObserverDocument = {
+ add: function (handler) {
+ var MO = MUTATION_OBSERVER();
+ if (MO) {
+ var documentElement = getDocument().documentElement;
+ var globalObserverData = domDataCore.get.call(documentElement, 'globalObserverData');
+ if (!globalObserverData) {
+ var observer = new MO(function (mutations) {
+ globalObserverData.handlers.forEach(function (handler) {
+ handler(mutations);
+ });
+ });
+ observer.observe(documentElement, {
+ childList: true,
+ subtree: true
+ });
+ globalObserverData = {
+ observer: observer,
+ handlers: []
+ };
+ domDataCore.set.call(documentElement, 'globalObserverData', globalObserverData);
+ }
+ globalObserverData.handlers.push(handler);
+ }
+ },
+ remove: function (handler) {
+ var documentElement = getDocument().documentElement;
+ var globalObserverData = domDataCore.get.call(documentElement, 'globalObserverData');
+ if (globalObserverData) {
+ var index = globalObserverData.handlers.indexOf(handler);
+ if (index >= 0) {
+ globalObserverData.handlers.splice(index, 1);
+ }
+ if (globalObserverData.handlers.length === 0) {
+ globalObserverData.observer.disconnect();
+ domDataCore.clean.call(documentElement, 'globalObserverData');
+ }
+ }
+ }
+ };
+ var makeMutationMethods = function (name) {
+ var mutationName = name.toLowerCase() + 'Nodes';
+ var getMutationData = function () {
+ var documentElement = getDocument().documentElement;
+ var mutationData = domDataCore.get.call(documentElement, mutationName + 'MutationData');
+ if (!mutationData) {
+ mutationData = {
+ name: mutationName,
+ handlers: [],
+ afterHandlers: [],
+ hander: null
+ };
+ if (MUTATION_OBSERVER()) {
+ domDataCore.set.call(documentElement, mutationName + 'MutationData', mutationData);
+ }
+ }
+ return mutationData;
+ };
+ var setup = function () {
+ var mutationData = getMutationData();
+ if (mutationData.handlers.length === 0 || mutationData.afterHandlers.length === 0) {
+ mutationData.handler = function (mutations) {
+ var dispatched = new CIDStore();
+ mutations.forEach(function (mutation) {
+ each(mutation[mutationName], function (mutatedNode) {
+ var children = mutatedNode.getElementsByTagName && makeArray(mutatedNode.getElementsByTagName('*'));
+ var alreadyChecked = dispatchIfListening(mutatedNode, mutationData, dispatched);
+ if (children && !alreadyChecked) {
+ for (var j = 0, child; (child = children[j]) !== undefined; j++) {
+ dispatchIfListening(child, mutationData, dispatched);
+ }
+ }
+ });
+ });
+ };
+ this.add(mutationData.handler);
+ }
+ return mutationData;
+ };
+ var teardown = function () {
+ var documentElement = getDocument().documentElement;
+ var mutationData = getMutationData();
+ if (mutationData.handlers.length === 0 && mutationData.afterHandlers.length === 0) {
+ this.remove(mutationData.handler);
+ domDataCore.clean.call(documentElement, mutationName + 'MutationData');
+ }
+ };
+ var createOnOffHandlers = function (name, handlerList) {
+ mutationObserverDocument['on' + name] = function (handler) {
+ var mutationData = setup.call(this);
+ mutationData[handlerList].push(handler);
+ };
+ mutationObserverDocument['off' + name] = function (handler) {
+ var mutationData = getMutationData();
+ var index = mutationData[handlerList].indexOf(handler);
+ if (index >= 0) {
+ mutationData[handlerList].splice(index, 1);
+ }
+ teardown.call(this);
+ };
+ };
+ var createHandlers = function (name) {
+ createOnOffHandlers(name, 'handlers');
+ createOnOffHandlers('After' + name, 'afterHandlers');
+ };
+ createHandlers(string.capitalize(mutationName));
+ };
+ makeMutationMethods('added');
+ makeMutationMethods('removed');
+ module.exports = mutationObserverDocument;
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/dom/mutation-observer/mutation-observer.js b/dist/amd/dom/mutation-observer/mutation-observer.js
new file mode 100644
index 00000000..d5af637d
--- /dev/null
+++ b/dist/amd/dom/mutation-observer/mutation-observer.js
@@ -0,0 +1,15 @@
+/*can-util@3.3.3#dom/mutation-observer/mutation-observer*/
+define(function (require, exports, module) {
+ (function (global) {
+ var global = require('../../js/global/global')();
+ var setMutationObserver;
+ module.exports = function (setMO) {
+ if (setMO !== undefined) {
+ setMutationObserver = setMO;
+ }
+ return setMutationObserver !== undefined ? setMutationObserver : global.MutationObserver || global.WebKitMutationObserver || global.MozMutationObserver;
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/assign/assign.js b/dist/amd/js/assign/assign.js
new file mode 100644
index 00000000..304bbb36
--- /dev/null
+++ b/dist/amd/js/assign/assign.js
@@ -0,0 +1,9 @@
+/*can-util@3.3.3#js/assign/assign*/
+define(function (require, exports, module) {
+ module.exports = function (d, s) {
+ for (var prop in s) {
+ d[prop] = s[prop];
+ }
+ return d;
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/cid-set/cid-set.js b/dist/amd/js/cid-set/cid-set.js
new file mode 100644
index 00000000..bbb86624
--- /dev/null
+++ b/dist/amd/js/cid-set/cid-set.js
@@ -0,0 +1,47 @@
+/*can-util@3.3.3#js/cid-set/cid-set*/
+define(function (require, exports, module) {
+ (function (global) {
+ var GLOBAL = require('../global/global');
+ var each = require('../each/each');
+ var getCID = require('../cid/get-cid');
+ var CIDSet;
+ if (GLOBAL().Set) {
+ CIDSet = GLOBAL().Set;
+ } else {
+ var CIDSet = function () {
+ this.values = {};
+ };
+ CIDSet.prototype.add = function (value) {
+ this.values[getCID(value)] = value;
+ };
+ CIDSet.prototype['delete'] = function (key) {
+ var has = getCID(key) in this.values;
+ if (has) {
+ delete this.values[getCID(key)];
+ }
+ return has;
+ };
+ CIDSet.prototype.forEach = function (cb, thisArg) {
+ each(this.values, cb, thisArg);
+ };
+ CIDSet.prototype.has = function (value) {
+ return getCID(value) in this.values;
+ };
+ CIDSet.prototype.clear = function (key) {
+ return this.values = {};
+ };
+ Object.defineProperty(CIDSet.prototype, 'size', {
+ get: function () {
+ var size = 0;
+ each(this.values, function () {
+ size++;
+ });
+ return size;
+ }
+ });
+ }
+ module.exports = CIDSet;
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/cid/cid.js b/dist/amd/js/cid/cid.js
new file mode 100644
index 00000000..e03e9a36
--- /dev/null
+++ b/dist/amd/js/cid/cid.js
@@ -0,0 +1,4 @@
+/*can-util@3.3.3#js/cid/cid*/
+define(function (require, exports, module) {
+ module.exports = require('can-cid');
+});
\ No newline at end of file
diff --git a/dist/amd/js/cid/get-cid.js b/dist/amd/js/cid/get-cid.js
new file mode 100644
index 00000000..c869948f
--- /dev/null
+++ b/dist/amd/js/cid/get-cid.js
@@ -0,0 +1,14 @@
+/*can-util@3.3.3#js/cid/get-cid*/
+define(function (require, exports, module) {
+ var CID = require('can-cid');
+ var domDataCore = require('../../dom/data/core');
+ module.exports = function (obj) {
+ if (typeof obj.nodeType === 'number') {
+ return domDataCore.cid.call(obj);
+ } else {
+ var type = typeof obj;
+ var isObject = type !== null && (type === 'object' || type === 'function');
+ return type + ':' + (isObject ? CID(obj) : obj);
+ }
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/deep-assign/deep-assign.js b/dist/amd/js/deep-assign/deep-assign.js
new file mode 100644
index 00000000..0d20c8e1
--- /dev/null
+++ b/dist/amd/js/deep-assign/deep-assign.js
@@ -0,0 +1,40 @@
+/*can-util@3.3.3#js/deep-assign/deep-assign*/
+define(function (require, exports, module) {
+ var isArray = require('../is-array/is-array');
+ var isFunction = require('../is-function/is-function');
+ var isPlainObject = require('../is-plain-object/is-plain-object');
+ function deepAssign() {
+ var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length;
+ if (typeof target !== 'object' && !isFunction(target)) {
+ target = {};
+ }
+ if (length === i) {
+ target = this;
+ --i;
+ }
+ for (; i < length; i++) {
+ if ((options = arguments[i]) != null) {
+ for (name in options) {
+ src = target[name];
+ copy = options[name];
+ if (target === copy) {
+ continue;
+ }
+ if (copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
+ if (copyIsArray) {
+ copyIsArray = false;
+ clone = src && isArray(src) ? src : [];
+ } else {
+ clone = src && isPlainObject(src) ? src : {};
+ }
+ target[name] = deepAssign(clone, copy);
+ } else if (copy !== undefined) {
+ target[name] = copy;
+ }
+ }
+ }
+ }
+ return target;
+ }
+ module.exports = deepAssign;
+});
\ No newline at end of file
diff --git a/dist/amd/js/dev/dev.js b/dist/amd/js/dev/dev.js
new file mode 100644
index 00000000..474633d8
--- /dev/null
+++ b/dist/amd/js/dev/dev.js
@@ -0,0 +1,13 @@
+/*can-util@3.3.3#js/dev/dev*/
+define(function (require, exports, module) {
+ var canLog = require('../log/log');
+ module.exports = {
+ warnTimeout: 5000,
+ logLevel: 0,
+ warn: function () {
+ },
+ log: function () {
+ },
+ _logger: canLog._logger
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/diff/diff.js b/dist/amd/js/diff/diff.js
new file mode 100644
index 00000000..d5991da0
--- /dev/null
+++ b/dist/amd/js/diff/diff.js
@@ -0,0 +1,54 @@
+/*can-util@3.3.3#js/diff/diff*/
+define(function (require, exports, module) {
+ var slice = [].slice;
+ var defaultIdentity = function (a, b) {
+ return a === b;
+ };
+ module.exports = exports = function (oldList, newList, identity) {
+ identity = identity || defaultIdentity;
+ var oldIndex = 0, newIndex = 0, oldLength = oldList.length, newLength = newList.length, patches = [];
+ while (oldIndex < oldLength && newIndex < newLength) {
+ var oldItem = oldList[oldIndex], newItem = newList[newIndex];
+ if (identity(oldItem, newItem)) {
+ oldIndex++;
+ newIndex++;
+ continue;
+ }
+ if (newIndex + 1 < newLength && identity(oldItem, newList[newIndex + 1])) {
+ patches.push({
+ index: newIndex,
+ deleteCount: 0,
+ insert: [newList[newIndex]]
+ });
+ oldIndex++;
+ newIndex += 2;
+ continue;
+ } else if (oldIndex + 1 < oldLength && identity(oldList[oldIndex + 1], newItem)) {
+ patches.push({
+ index: newIndex,
+ deleteCount: 1,
+ insert: []
+ });
+ oldIndex += 2;
+ newIndex++;
+ continue;
+ } else {
+ patches.push({
+ index: newIndex,
+ deleteCount: oldLength - oldIndex,
+ insert: slice.call(newList, newIndex)
+ });
+ return patches;
+ }
+ }
+ if (newIndex === newLength && oldIndex === oldLength) {
+ return patches;
+ }
+ patches.push({
+ index: newIndex,
+ deleteCount: oldLength - oldIndex,
+ insert: slice.call(newList, newIndex)
+ });
+ return patches;
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/each/each.js b/dist/amd/js/each/each.js
new file mode 100644
index 00000000..dd7d5f2f
--- /dev/null
+++ b/dist/amd/js/each/each.js
@@ -0,0 +1,35 @@
+/*can-util@3.3.3#js/each/each*/
+define(function (require, exports, module) {
+ var isArrayLike = require('../is-array-like/is-array-like');
+ var has = Object.prototype.hasOwnProperty;
+ var isIterable = require('../is-iterable/is-iterable');
+ var types = require('can-types');
+ function each(elements, callback, context) {
+ var i = 0, key, len, item;
+ if (elements) {
+ if (isArrayLike(elements)) {
+ for (len = elements.length; i < len; i++) {
+ item = elements[i];
+ if (callback.call(context || item, item, i, elements) === false) {
+ break;
+ }
+ }
+ } else if (isIterable(elements)) {
+ var iter = elements[types.iterator]();
+ var res, value;
+ while (!(res = iter.next()).done) {
+ value = res.value;
+ callback.call(context || elements, Array.isArray(value) ? value[1] : value, value[0]);
+ }
+ } else if (typeof elements === 'object') {
+ for (key in elements) {
+ if (has.call(elements, key) && callback.call(context || elements[key], elements[key], key, elements) === false) {
+ break;
+ }
+ }
+ }
+ }
+ return elements;
+ }
+ module.exports = each;
+});
\ No newline at end of file
diff --git a/dist/amd/js/get/get.js b/dist/amd/js/get/get.js
new file mode 100644
index 00000000..27ee201b
--- /dev/null
+++ b/dist/amd/js/get/get.js
@@ -0,0 +1,17 @@
+/*can-util@3.3.3#js/get/get*/
+define(function (require, exports, module) {
+ var isContainer = require('../is-container/is-container');
+ function get(obj, name) {
+ var parts = typeof name !== 'undefined' ? (name + '').replace(/\[/g, '.').replace(/]/g, '').split('.') : [], length = parts.length, current, i, container;
+ if (!length) {
+ return obj;
+ }
+ current = obj;
+ for (i = 0; i < length && isContainer(current); i++) {
+ container = current;
+ current = container[parts[i]];
+ }
+ return current;
+ }
+ module.exports = get;
+});
\ No newline at end of file
diff --git a/dist/amd/js/global/global.js b/dist/amd/js/global/global.js
new file mode 100644
index 00000000..b090b26d
--- /dev/null
+++ b/dist/amd/js/global/global.js
@@ -0,0 +1,18 @@
+/*can-util@3.3.3#js/global/global*/
+define(function (require, exports, module) {
+ (function (global) {
+ var GLOBAL;
+ module.exports = function (setGlobal) {
+ if (setGlobal !== undefined) {
+ GLOBAL = setGlobal;
+ }
+ if (GLOBAL) {
+ return GLOBAL;
+ } else {
+ return GLOBAL = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : typeof process === 'object' && {}.toString.call(process) === '[object process]' ? global : window;
+ }
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/import/import.js b/dist/amd/js/import/import.js
new file mode 100644
index 00000000..f58e945c
--- /dev/null
+++ b/dist/amd/js/import/import.js
@@ -0,0 +1,28 @@
+/*can-util@3.3.3#js/import/import*/
+define(function (require, exports, module) {
+ (function (global) {
+ var isFunction = require('../is-function/is-function');
+ var global = require('../global/global')();
+ module.exports = function (moduleName, parentName) {
+ return new Promise(function (resolve, reject) {
+ try {
+ if (typeof global.System === 'object' && isFunction(global.System['import'])) {
+ global.System['import'](moduleName, { name: parentName }).then(resolve, reject);
+ } else if (global.define && global.define.amd) {
+ global.require([moduleName], function (value) {
+ resolve(value);
+ });
+ } else if (global.require) {
+ resolve(global.require(moduleName));
+ } else {
+ resolve();
+ }
+ } catch (err) {
+ reject(err);
+ }
+ });
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-array-like/is-array-like.js b/dist/amd/js/is-array-like/is-array-like.js
new file mode 100644
index 00000000..b0c1a616
--- /dev/null
+++ b/dist/amd/js/is-array-like/is-array-like.js
@@ -0,0 +1,14 @@
+/*can-util@3.3.3#js/is-array-like/is-array-like*/
+define(function (require, exports, module) {
+ function isArrayLike(obj) {
+ var type = typeof obj;
+ if (type === 'string') {
+ return true;
+ } else if (type === 'number') {
+ return false;
+ }
+ var length = obj && type !== 'boolean' && typeof obj !== 'number' && 'length' in obj && obj.length;
+ return typeof obj !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj);
+ }
+ module.exports = isArrayLike;
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-array/is-array.js b/dist/amd/js/is-array/is-array.js
new file mode 100644
index 00000000..b0d2a94c
--- /dev/null
+++ b/dist/amd/js/is-array/is-array.js
@@ -0,0 +1,6 @@
+/*can-util@3.3.3#js/is-array/is-array*/
+define(function (require, exports, module) {
+ module.exports = function (arr) {
+ return Array.isArray(arr);
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-browser-window/is-browser-window.js b/dist/amd/js/is-browser-window/is-browser-window.js
new file mode 100644
index 00000000..4df84dd6
--- /dev/null
+++ b/dist/amd/js/is-browser-window/is-browser-window.js
@@ -0,0 +1,10 @@
+/*can-util@3.3.3#js/is-browser-window/is-browser-window*/
+define(function (require, exports, module) {
+ (function (global) {
+ module.exports = function () {
+ return typeof window !== 'undefined' && typeof document !== 'undefined' && typeof SimpleDOM === 'undefined';
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-container/is-container.js b/dist/amd/js/is-container/is-container.js
new file mode 100644
index 00000000..9ffe5a41
--- /dev/null
+++ b/dist/amd/js/is-container/is-container.js
@@ -0,0 +1,6 @@
+/*can-util@3.3.3#js/is-container/is-container*/
+define(function (require, exports, module) {
+ module.exports = function (current) {
+ return /^f|^o/.test(typeof current);
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-empty-object/is-empty-object.js b/dist/amd/js/is-empty-object/is-empty-object.js
new file mode 100644
index 00000000..6be7a3ab
--- /dev/null
+++ b/dist/amd/js/is-empty-object/is-empty-object.js
@@ -0,0 +1,9 @@
+/*can-util@3.3.3#js/is-empty-object/is-empty-object*/
+define(function (require, exports, module) {
+ module.exports = function (obj) {
+ for (var prop in obj) {
+ return false;
+ }
+ return true;
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-function/is-function.js b/dist/amd/js/is-function/is-function.js
new file mode 100644
index 00000000..b844bdc9
--- /dev/null
+++ b/dist/amd/js/is-function/is-function.js
@@ -0,0 +1,14 @@
+/*can-util@3.3.3#js/is-function/is-function*/
+define(function (require, exports, module) {
+ var isFunction = function () {
+ if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') {
+ return function (value) {
+ return Object.prototype.toString.call(value) === '[object Function]';
+ };
+ }
+ return function (value) {
+ return typeof value === 'function';
+ };
+ }();
+ module.exports = isFunction;
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-iterable/is-iterable.js b/dist/amd/js/is-iterable/is-iterable.js
new file mode 100644
index 00000000..9675a5af
--- /dev/null
+++ b/dist/amd/js/is-iterable/is-iterable.js
@@ -0,0 +1,7 @@
+/*can-util@3.3.3#js/is-iterable/is-iterable*/
+define(function (require, exports, module) {
+ var types = require('can-types');
+ module.exports = function (obj) {
+ return obj && !!obj[types.iterator];
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-node/is-node.js b/dist/amd/js/is-node/is-node.js
new file mode 100644
index 00000000..85bc4773
--- /dev/null
+++ b/dist/amd/js/is-node/is-node.js
@@ -0,0 +1,10 @@
+/*can-util@3.3.3#js/is-node/is-node*/
+define(function (require, exports, module) {
+ (function (global) {
+ module.exports = function () {
+ return typeof process === 'object' && {}.toString.call(process) === '[object process]';
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-plain-object/is-plain-object.js b/dist/amd/js/is-plain-object/is-plain-object.js
new file mode 100644
index 00000000..8d1c1261
--- /dev/null
+++ b/dist/amd/js/is-plain-object/is-plain-object.js
@@ -0,0 +1,24 @@
+/*can-util@3.3.3#js/is-plain-object/is-plain-object*/
+define(function (require, exports, module) {
+ var core_hasOwn = Object.prototype.hasOwnProperty;
+ function isWindow(obj) {
+ return obj !== null && obj == obj.window;
+ }
+ function isPlainObject(obj) {
+ if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) {
+ return false;
+ }
+ try {
+ if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) {
+ return false;
+ }
+ } catch (e) {
+ return false;
+ }
+ var key;
+ for (key in obj) {
+ }
+ return key === undefined || core_hasOwn.call(obj, key);
+ }
+ module.exports = isPlainObject;
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-promise/is-promise.js b/dist/amd/js/is-promise/is-promise.js
new file mode 100644
index 00000000..80c36673
--- /dev/null
+++ b/dist/amd/js/is-promise/is-promise.js
@@ -0,0 +1,7 @@
+/*can-util@3.3.3#js/is-promise/is-promise*/
+define(function (require, exports, module) {
+ var types = require('can-types');
+ module.exports = function (obj) {
+ return types.isPromise(obj);
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-string/is-string.js b/dist/amd/js/is-string/is-string.js
new file mode 100644
index 00000000..3ad5d4d8
--- /dev/null
+++ b/dist/amd/js/is-string/is-string.js
@@ -0,0 +1,6 @@
+/*can-util@3.3.3#js/is-string/is-string*/
+define(function (require, exports, module) {
+ module.exports = function isString(obj) {
+ return typeof obj === 'string';
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/is-web-worker/is-web-worker.js b/dist/amd/js/is-web-worker/is-web-worker.js
new file mode 100644
index 00000000..f604e823
--- /dev/null
+++ b/dist/amd/js/is-web-worker/is-web-worker.js
@@ -0,0 +1,10 @@
+/*can-util@3.3.3#js/is-web-worker/is-web-worker*/
+define(function (require, exports, module) {
+ (function (global) {
+ module.exports = function () {
+ return typeof WorkerGlobalScope !== 'undefined' && this instanceof WorkerGlobalScope;
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/join-uris/join-uris.js b/dist/amd/js/join-uris/join-uris.js
new file mode 100644
index 00000000..298b4f4c
--- /dev/null
+++ b/dist/amd/js/join-uris/join-uris.js
@@ -0,0 +1,20 @@
+/*can-util@3.3.3#js/join-uris/join-uris*/
+define(function (require, exports, module) {
+ var parseURI = require('../parse-uri/parse-uri');
+ module.exports = function (base, href) {
+ function removeDotSegments(input) {
+ var output = [];
+ input.replace(/^(\.\.?(\/|$))+/, '').replace(/\/(\.(\/|$))+/g, '/').replace(/\/\.\.$/, '/../').replace(/\/?[^\/]*/g, function (p) {
+ if (p === '/..') {
+ output.pop();
+ } else {
+ output.push(p);
+ }
+ });
+ return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
+ }
+ href = parseURI(href || '');
+ base = parseURI(base || '');
+ return !href || !base ? null : (href.protocol || base.protocol) + (href.protocol || href.authority ? href.authority : base.authority) + removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : href.pathname ? (base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname : base.pathname) + (href.protocol || href.authority || href.pathname ? href.search : href.search || base.search) + href.hash;
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/js.js b/dist/amd/js/js.js
new file mode 100644
index 00000000..89e4945a
--- /dev/null
+++ b/dist/amd/js/js.js
@@ -0,0 +1,34 @@
+/*can-util@3.3.3#js/js*/
+define(function (require, exports, module) {
+ (function (global) {
+ module.exports = {
+ assign: require('./assign/assign'),
+ cid: require('./cid/cid'),
+ deepAssign: require('./deep-assign/deep-assign'),
+ dev: require('./dev/dev'),
+ diff: require('./diff/diff'),
+ each: require('./each/each'),
+ global: require('./global/global'),
+ 'import': require('./import/import'),
+ isArray: require('./is-array/is-array'),
+ isArrayLike: require('./is-array-like/is-array-like'),
+ isBrowserWindow: require('./is-browser-window/is-browser-window'),
+ isEmptyObject: require('./is-empty-object/is-empty-object'),
+ isFunction: require('./is-function/is-function'),
+ isNode: require('./is-node/is-node'),
+ isPlainObject: require('./is-plain-object/is-plain-object'),
+ isPromise: require('./is-promise/is-promise'),
+ isString: require('./is-string/is-string'),
+ isWebWorker: require('./is-web-worker/is-web-worker'),
+ joinURIs: require('./join-uris/join-uris'),
+ last: require('./last/last'),
+ makeArray: require('./make-array/make-array'),
+ omit: require('./omit/omit'),
+ setImmediate: require('./set-immediate/set-immediate'),
+ string: require('./string/string'),
+ types: require('./types/types')
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/last/last.js b/dist/amd/js/last/last.js
new file mode 100644
index 00000000..f78b78c9
--- /dev/null
+++ b/dist/amd/js/last/last.js
@@ -0,0 +1,6 @@
+/*can-util@3.3.3#js/last/last*/
+define(function (require, exports, module) {
+ module.exports = function (arr) {
+ return arr && arr[arr.length - 1];
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/log/log.js b/dist/amd/js/log/log.js
new file mode 100644
index 00000000..bf32c33c
--- /dev/null
+++ b/dist/amd/js/log/log.js
@@ -0,0 +1,47 @@
+/*can-util@3.3.3#js/log/log*/
+define(function (require, exports, module) {
+ exports.warnTimeout = 5000;
+ exports.logLevel = 0;
+ exports.warn = function (out) {
+ var ll = this.logLevel;
+ if (ll < 2) {
+ Array.prototype.unshift.call(arguments, 'WARN:');
+ if (typeof console !== 'undefined' && console.warn) {
+ this._logger('warn', Array.prototype.slice.call(arguments));
+ } else if (typeof console !== 'undefined' && console.log) {
+ this._logger('log', Array.prototype.slice.call(arguments));
+ } else if (window && window.opera && window.opera.postError) {
+ window.opera.postError('CanJS WARNING: ' + out);
+ }
+ }
+ };
+ exports.log = function (out) {
+ var ll = this.logLevel;
+ if (ll < 1) {
+ if (typeof console !== 'undefined' && console.log) {
+ Array.prototype.unshift.call(arguments, 'INFO:');
+ this._logger('log', Array.prototype.slice.call(arguments));
+ } else if (window && window.opera && window.opera.postError) {
+ window.opera.postError('CanJS INFO: ' + out);
+ }
+ }
+ };
+ exports.error = function (out) {
+ var ll = this.logLevel;
+ if (ll < 1) {
+ if (typeof console !== 'undefined' && console.error) {
+ Array.prototype.unshift.call(arguments, 'ERROR:');
+ this._logger('error', Array.prototype.slice.call(arguments));
+ } else if (window && window.opera && window.opera.postError) {
+ window.opera.postError('ERROR: ' + out);
+ }
+ }
+ };
+ exports._logger = function (type, arr) {
+ try {
+ console[type].apply(console, arr);
+ } catch (e) {
+ console[type](arr);
+ }
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/make-array/make-array.js b/dist/amd/js/make-array/make-array.js
new file mode 100644
index 00000000..2f7ec75f
--- /dev/null
+++ b/dist/amd/js/make-array/make-array.js
@@ -0,0 +1,17 @@
+/*can-util@3.3.3#js/make-array/make-array*/
+define(function (require, exports, module) {
+ var each = require('../each/each');
+ var isArrayLike = require('../is-array-like/is-array-like');
+ function makeArray(element) {
+ var ret = [];
+ if (isArrayLike(element)) {
+ each(element, function (a, i) {
+ ret[i] = a;
+ });
+ } else if (element === 0 || element) {
+ ret.push(element);
+ }
+ return ret;
+ }
+ module.exports = makeArray;
+});
\ No newline at end of file
diff --git a/dist/amd/js/omit/omit.js b/dist/amd/js/omit/omit.js
new file mode 100644
index 00000000..851d657c
--- /dev/null
+++ b/dist/amd/js/omit/omit.js
@@ -0,0 +1,12 @@
+/*can-util@3.3.3#js/omit/omit*/
+define(function (require, exports, module) {
+ module.exports = function (source, propsToOmit) {
+ var result = {};
+ for (var prop in source) {
+ if (propsToOmit.indexOf(prop) < 0) {
+ result[prop] = source[prop];
+ }
+ }
+ return result;
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/param/param.js b/dist/amd/js/param/param.js
new file mode 100644
index 00000000..cf99f474
--- /dev/null
+++ b/dist/amd/js/param/param.js
@@ -0,0 +1,27 @@
+/*can-util@3.3.3#js/param/param*/
+define(function (require, exports, module) {
+ var isArray = require('../is-array/is-array');
+ var namespace = require('can-namespace');
+ function buildParam(prefix, obj, add) {
+ if (isArray(obj)) {
+ for (var i = 0, l = obj.length; i < l; ++i) {
+ add(prefix + '[]', obj[i]);
+ }
+ } else if (obj && typeof obj === 'object') {
+ for (var name in obj) {
+ buildParam(prefix + '[' + name + ']', obj[name], add);
+ }
+ } else {
+ add(prefix, obj);
+ }
+ }
+ module.exports = namespace.param = function param(object) {
+ var pairs = [], add = function (key, value) {
+ pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
+ };
+ for (var name in object) {
+ buildParam(name, object[name], add);
+ }
+ return pairs.join('&').replace(/%20/g, '+');
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/parse-uri/parse-uri.js b/dist/amd/js/parse-uri/parse-uri.js
new file mode 100644
index 00000000..342592cc
--- /dev/null
+++ b/dist/amd/js/parse-uri/parse-uri.js
@@ -0,0 +1,17 @@
+/*can-util@3.3.3#js/parse-uri/parse-uri*/
+define(function (require, exports, module) {
+ module.exports = function (url) {
+ var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ return m ? {
+ href: m[0] || '',
+ protocol: m[1] || '',
+ authority: m[2] || '',
+ host: m[3] || '',
+ hostname: m[4] || '',
+ port: m[5] || '',
+ pathname: m[6] || '',
+ search: m[7] || '',
+ hash: m[8] || ''
+ } : null;
+ };
+});
\ No newline at end of file
diff --git a/dist/amd/js/set-immediate/set-immediate.js b/dist/amd/js/set-immediate/set-immediate.js
new file mode 100644
index 00000000..4f5f410b
--- /dev/null
+++ b/dist/amd/js/set-immediate/set-immediate.js
@@ -0,0 +1,11 @@
+/*can-util@3.3.3#js/set-immediate/set-immediate*/
+define(function (require, exports, module) {
+ (function (global) {
+ var global = require('../global/global')();
+ module.exports = global.setImmediate || function (cb) {
+ return setTimeout(cb, 0);
+ };
+ }(function () {
+ return this;
+ }()));
+});
\ No newline at end of file
diff --git a/dist/amd/js/string/string.js b/dist/amd/js/string/string.js
new file mode 100644
index 00000000..f944813e
--- /dev/null
+++ b/dist/amd/js/string/string.js
@@ -0,0 +1,76 @@
+/*can-util@3.3.3#js/string/string*/
+define(function (require, exports, module) {
+ var get = require('../get/get');
+ var isContainer = require('../is-container/is-container');
+ var canDev = require('../dev/dev');
+ var isArray = require('../is-array/is-array');
+ var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, convertBadValues = function (content) {
+ var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN';
+ return '' + (isInvalid ? '' : content);
+ }, deleteAtPath = function (data, path) {
+ var parts = path ? path.replace(/\[/g, '.').replace(/]/g, '').split('.') : [];
+ var current = data;
+ for (var i = 0; i < parts.length - 1; i++) {
+ if (current) {
+ current = current[parts[i]];
+ }
+ }
+ if (current) {
+ delete current[parts[parts.length - 1]];
+ }
+ };
+ var string = {
+ esc: function (content) {
+ return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, ''');
+ },
+ getObject: function (name, roots) {
+ roots = isArray(roots) ? roots : [roots || window];
+ var result, l = roots.length;
+ for (var i = 0; i < l; i++) {
+ result = get(roots[i], name);
+ if (result) {
+ return result;
+ }
+ }
+ },
+ capitalize: function (s, cache) {
+ return s.charAt(0).toUpperCase() + s.slice(1);
+ },
+ camelize: function (str) {
+ return convertBadValues(str).replace(strHyphenMatch, function (match, chr) {
+ return chr ? chr.toUpperCase() : '';
+ });
+ },
+ hyphenate: function (str) {
+ return convertBadValues(str).replace(strCamelMatch, function (str, offset) {
+ return str.charAt(0) + '-' + str.charAt(1).toLowerCase();
+ });
+ },
+ underscore: function (s) {
+ return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase();
+ },
+ sub: function (str, data, remove) {
+ var obs = [];
+ str = str || '';
+ obs.push(str.replace(strReplacer, function (whole, inside) {
+ var ob = get(data, inside);
+ if (remove === true) {
+ deleteAtPath(data, inside);
+ }
+ if (ob === undefined || ob === null) {
+ obs = null;
+ return '';
+ }
+ if (isContainer(ob) && obs) {
+ obs.push(ob);
+ return '';
+ }
+ return '' + ob;
+ }));
+ return obs === null ? obs : obs.length <= 1 ? obs[0] : obs;
+ },
+ replacer: strReplacer,
+ undHash: strUndHash
+ };
+ module.exports = string;
+});
\ No newline at end of file
diff --git a/dist/amd/js/types/types.js b/dist/amd/js/types/types.js
new file mode 100644
index 00000000..ba424dd5
--- /dev/null
+++ b/dist/amd/js/types/types.js
@@ -0,0 +1,4 @@
+/*can-util@3.3.3#js/types/types*/
+define(function (require, exports, module) {
+ module.exports = require('can-types');
+});
\ No newline at end of file
diff --git a/dist/global/can-util.js b/dist/global/can-util.js
new file mode 100644
index 00000000..ce199200
--- /dev/null
+++ b/dist/global/can-util.js
@@ -0,0 +1,2250 @@
+/*[global-shim-start]*/
+(function(exports, global, doEval){ // jshint ignore:line
+ var origDefine = global.define;
+
+ var get = function(name){
+ var parts = name.split("."),
+ cur = global,
+ i;
+ for(i = 0 ; i < parts.length; i++){
+ if(!cur) {
+ break;
+ }
+ cur = cur[parts[i]];
+ }
+ return cur;
+ };
+ var set = function(name, val){
+ var parts = name.split("."),
+ cur = global,
+ i, part, next;
+ for(i = 0; i < parts.length - 1; i++) {
+ part = parts[i];
+ next = cur[part];
+ if(!next) {
+ next = cur[part] = {};
+ }
+ cur = next;
+ }
+ part = parts[parts.length - 1];
+ cur[part] = val;
+ };
+ var useDefault = function(mod){
+ if(!mod || !mod.__esModule) return false;
+ var esProps = { __esModule: true, "default": true };
+ for(var p in mod) {
+ if(!esProps[p]) return false;
+ }
+ return true;
+ };
+ var modules = (global.define && global.define.modules) ||
+ (global._define && global._define.modules) || {};
+ var ourDefine = global.define = function(moduleName, deps, callback){
+ var module;
+ if(typeof deps === "function") {
+ callback = deps;
+ deps = [];
+ }
+ var args = [],
+ i;
+ for(i =0; i < deps.length; i++) {
+ args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) );
+ }
+ // CJS has no dependencies but 3 callback arguments
+ if(!deps.length && callback.length) {
+ module = { exports: {} };
+ var require = function(name) {
+ return exports[name] ? get(exports[name]) : modules[name];
+ };
+ args.push(require, module.exports, module);
+ }
+ // Babel uses the exports and module object.
+ else if(!args[0] && deps[0] === "exports") {
+ module = { exports: {} };
+ args[0] = module.exports;
+ if(deps[1] === "module") {
+ args[1] = module;
+ }
+ } else if(!args[0] && deps[0] === "module") {
+ args[0] = { id: moduleName };
+ }
+
+ global.define = origDefine;
+ var result = callback ? callback.apply(null, args) : undefined;
+ global.define = ourDefine;
+
+ // Favor CJS module.exports over the return value
+ result = module && module.exports ? module.exports : result;
+ modules[moduleName] = result;
+
+ // Set global exports
+ var globalExport = exports[moduleName];
+ if(globalExport && !get(globalExport)) {
+ if(useDefault(result)) {
+ result = result["default"];
+ }
+ set(globalExport, result);
+ }
+ };
+ global.define.orig = origDefine;
+ global.define.modules = modules;
+ global.define.amd = true;
+ ourDefine("@loader", [], function(){
+ // shim for @@global-helpers
+ var noop = function(){};
+ return {
+ get: function(){
+ return { prepareGlobal: noop, retrieveGlobal: noop };
+ },
+ global: global,
+ __exec: function(__load){
+ doEval(__load.source, global);
+ }
+ };
+ });
+}
+)({"can-namespace":"can"},window,function(__$source__, __$global__) { // jshint ignore:line
+ eval("(function() { " + __$source__ + " \n }).call(__$global__);");
+}
+)
+/*can-util@3.3.3#js/is-array/is-array*/
+define('can-util/js/is-array/is-array', function (require, exports, module) {
+ module.exports = function (arr) {
+ return Array.isArray(arr);
+ };
+});
+/*can-util@3.3.3#js/is-function/is-function*/
+define('can-util/js/is-function/is-function', function (require, exports, module) {
+ var isFunction = function () {
+ if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') {
+ return function (value) {
+ return Object.prototype.toString.call(value) === '[object Function]';
+ };
+ }
+ return function (value) {
+ return typeof value === 'function';
+ };
+ }();
+ module.exports = isFunction;
+});
+/*can-util@3.3.3#js/is-plain-object/is-plain-object*/
+define('can-util/js/is-plain-object/is-plain-object', function (require, exports, module) {
+ var core_hasOwn = Object.prototype.hasOwnProperty;
+ function isWindow(obj) {
+ return obj !== null && obj == obj.window;
+ }
+ function isPlainObject(obj) {
+ if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) {
+ return false;
+ }
+ try {
+ if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) {
+ return false;
+ }
+ } catch (e) {
+ return false;
+ }
+ var key;
+ for (key in obj) {
+ }
+ return key === undefined || core_hasOwn.call(obj, key);
+ }
+ module.exports = isPlainObject;
+});
+/*can-util@3.3.3#js/deep-assign/deep-assign*/
+define('can-util/js/deep-assign/deep-assign', function (require, exports, module) {
+ var isArray = require('can-util/js/is-array/is-array');
+ var isFunction = require('can-util/js/is-function/is-function');
+ var isPlainObject = require('can-util/js/is-plain-object/is-plain-object');
+ function deepAssign() {
+ var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length;
+ if (typeof target !== 'object' && !isFunction(target)) {
+ target = {};
+ }
+ if (length === i) {
+ target = this;
+ --i;
+ }
+ for (; i < length; i++) {
+ if ((options = arguments[i]) != null) {
+ for (name in options) {
+ src = target[name];
+ copy = options[name];
+ if (target === copy) {
+ continue;
+ }
+ if (copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
+ if (copyIsArray) {
+ copyIsArray = false;
+ clone = src && isArray(src) ? src : [];
+ } else {
+ clone = src && isPlainObject(src) ? src : {};
+ }
+ target[name] = deepAssign(clone, copy);
+ } else if (copy !== undefined) {
+ target[name] = copy;
+ }
+ }
+ }
+ }
+ return target;
+ }
+ module.exports = deepAssign;
+});
+/*can-util@3.3.3#js/omit/omit*/
+define('can-util/js/omit/omit', function (require, exports, module) {
+ module.exports = function (source, propsToOmit) {
+ var result = {};
+ for (var prop in source) {
+ if (propsToOmit.indexOf(prop) < 0) {
+ result[prop] = source[prop];
+ }
+ }
+ return result;
+ };
+});
+/*can-namespace@1.0.0#can-namespace*/
+define('can-namespace', function (require, exports, module) {
+ module.exports = {};
+});
+/*can-util@3.3.3#js/global/global*/
+define('can-util/js/global/global', function (require, exports, module) {
+ (function (global) {
+ var GLOBAL;
+ module.exports = function (setGlobal) {
+ if (setGlobal !== undefined) {
+ GLOBAL = setGlobal;
+ }
+ if (GLOBAL) {
+ return GLOBAL;
+ } else {
+ return GLOBAL = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : typeof process === 'object' && {}.toString.call(process) === '[object process]' ? global : window;
+ }
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/assign/assign*/
+define('can-util/js/assign/assign', function (require, exports, module) {
+ module.exports = function (d, s) {
+ for (var prop in s) {
+ d[prop] = s[prop];
+ }
+ return d;
+ };
+});
+/*can-util@3.3.3#js/parse-uri/parse-uri*/
+define('can-util/js/parse-uri/parse-uri', function (require, exports, module) {
+ module.exports = function (url) {
+ var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ return m ? {
+ href: m[0] || '',
+ protocol: m[1] || '',
+ authority: m[2] || '',
+ host: m[3] || '',
+ hostname: m[4] || '',
+ port: m[5] || '',
+ pathname: m[6] || '',
+ search: m[7] || '',
+ hash: m[8] || ''
+ } : null;
+ };
+});
+/*can-util@3.3.3#js/param/param*/
+define('can-util/js/param/param', function (require, exports, module) {
+ var isArray = require('can-util/js/is-array/is-array');
+ var namespace = require('can-namespace');
+ function buildParam(prefix, obj, add) {
+ if (isArray(obj)) {
+ for (var i = 0, l = obj.length; i < l; ++i) {
+ add(prefix + '[]', obj[i]);
+ }
+ } else if (obj && typeof obj === 'object') {
+ for (var name in obj) {
+ buildParam(prefix + '[' + name + ']', obj[name], add);
+ }
+ } else {
+ add(prefix, obj);
+ }
+ }
+ module.exports = namespace.param = function param(object) {
+ var pairs = [], add = function (key, value) {
+ pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
+ };
+ for (var name in object) {
+ buildParam(name, object[name], add);
+ }
+ return pairs.join('&').replace(/%20/g, '+');
+ };
+});
+/*can-util@3.3.3#dom/ajax/ajax*/
+define('can-util/dom/ajax/ajax', function (require, exports, module) {
+ (function (global) {
+ var Global = require('can-util/js/global/global');
+ var assign = require('can-util/js/assign/assign');
+ var namespace = require('can-namespace');
+ var parseURI = require('can-util/js/parse-uri/parse-uri');
+ var param = require('can-util/js/param/param');
+ var xhrs = [
+ function () {
+ return new XMLHttpRequest();
+ },
+ function () {
+ return new ActiveXObject('Microsoft.XMLHTTP');
+ },
+ function () {
+ return new ActiveXObject('MSXML2.XMLHTTP.3.0');
+ },
+ function () {
+ return new ActiveXObject('MSXML2.XMLHTTP');
+ }
+ ], _xhrf = null;
+ var originUrl = parseURI(Global().location.href);
+ var makeXhr = function () {
+ if (_xhrf != null) {
+ return _xhrf();
+ }
+ for (var i = 0, l = xhrs.length; i < l; i++) {
+ try {
+ var f = xhrs[i], req = f();
+ if (req != null) {
+ _xhrf = f;
+ return req;
+ }
+ } catch (e) {
+ continue;
+ }
+ }
+ return function () {
+ };
+ };
+ var _xhrResp = function (xhr, options) {
+ switch (options.dataType || xhr.getResponseHeader('Content-Type').split(';')[0]) {
+ case 'text/xml':
+ case 'xml':
+ return xhr.responseXML;
+ case 'text/json':
+ case 'application/json':
+ case 'text/javascript':
+ case 'application/javascript':
+ case 'application/x-javascript':
+ case 'json':
+ return JSON.parse(xhr.responseText);
+ default:
+ return xhr.responseText;
+ }
+ };
+ module.exports = namespace.ajax = function (o) {
+ var xhr = makeXhr(), timer, n = 0;
+ var deferred = {};
+ var promise = new Promise(function (resolve, reject) {
+ deferred.resolve = resolve;
+ deferred.reject = reject;
+ });
+ var requestUrl;
+ promise.abort = function () {
+ xhr.abort();
+ };
+ o = assign({
+ userAgent: 'XMLHttpRequest',
+ lang: 'en',
+ type: 'GET',
+ data: null,
+ dataType: 'json'
+ }, o);
+ if (o.crossDomain == null) {
+ try {
+ requestUrl = parseURI(o.url);
+ o.crossDomain = !!(requestUrl.protocol && requestUrl.protocol !== originUrl.protocol || requestUrl.host && requestUrl.host !== originUrl.host);
+ } catch (e) {
+ o.crossDomain = true;
+ }
+ }
+ if (o.timeout) {
+ timer = setTimeout(function () {
+ xhr.abort();
+ if (o.timeoutFn) {
+ o.timeoutFn(o.url);
+ }
+ }, o.timeout);
+ }
+ xhr.onreadystatechange = function () {
+ try {
+ if (xhr.readyState === 4) {
+ if (timer) {
+ clearTimeout(timer);
+ }
+ if (xhr.status < 300) {
+ if (o.success) {
+ o.success(_xhrResp(xhr, o));
+ }
+ } else if (o.error) {
+ o.error(xhr, xhr.status, xhr.statusText);
+ }
+ if (o.complete) {
+ o.complete(xhr, xhr.statusText);
+ }
+ if (xhr.status >= 200 && xhr.status < 300) {
+ deferred.resolve(_xhrResp(xhr, o));
+ } else {
+ deferred.reject(xhr);
+ }
+ } else if (o.progress) {
+ o.progress(++n);
+ }
+ } catch (e) {
+ deferred.reject(e);
+ }
+ };
+ var url = o.url, data = null, type = o.type.toUpperCase();
+ var isPost = type === 'POST' || type === 'PUT';
+ if (!isPost && o.data) {
+ url += '?' + param(o.data);
+ }
+ xhr.open(type, url);
+ var isSimpleCors = o.crossDomain && [
+ 'GET',
+ 'POST',
+ 'HEAD'
+ ].indexOf(type) !== -1;
+ if (isPost) {
+ var isJson = o.dataType.indexOf('json') >= 0;
+ data = isJson && !isSimpleCors ? typeof o.data === 'object' ? JSON.stringify(o.data) : o.data : param(o.data);
+ xhr.setRequestHeader('Content-Type', isJson && !isSimpleCors ? 'application/json' : 'application/x-www-form-urlencoded');
+ }
+ if (!isSimpleCors) {
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ }
+ xhr.send(data);
+ return promise;
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/set-immediate/set-immediate*/
+define('can-util/js/set-immediate/set-immediate', function (require, exports, module) {
+ (function (global) {
+ var global = require('can-util/js/global/global')();
+ module.exports = global.setImmediate || function (cb) {
+ return setTimeout(cb, 0);
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#dom/document/document*/
+define('can-util/dom/document/document', function (require, exports, module) {
+ (function (global) {
+ var global = require('can-util/js/global/global');
+ var setDocument;
+ module.exports = function (setDoc) {
+ if (setDoc) {
+ setDocument = setDoc;
+ }
+ return setDocument || global().document;
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#dom/is-of-global-document/is-of-global-document*/
+define('can-util/dom/is-of-global-document/is-of-global-document', function (require, exports, module) {
+ var getDocument = require('can-util/dom/document/document');
+ module.exports = function (el) {
+ return (el.ownerDocument || el) === getDocument();
+ };
+});
+/*can-util@3.3.3#js/is-empty-object/is-empty-object*/
+define('can-util/js/is-empty-object/is-empty-object', function (require, exports, module) {
+ module.exports = function (obj) {
+ for (var prop in obj) {
+ return false;
+ }
+ return true;
+ };
+});
+/*can-util@3.3.3#dom/data/core*/
+define('can-util/dom/data/core', function (require, exports, module) {
+ var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
+ var data = {};
+ var expando = 'can' + new Date();
+ var uuid = 0;
+ var setData = function (name, value) {
+ var id = this[expando] || (this[expando] = ++uuid), store = data[id], newStore = false;
+ if (!data[id]) {
+ newStore = true;
+ store = data[id] = {};
+ }
+ if (name !== undefined) {
+ store[name] = value;
+ }
+ return newStore;
+ };
+ var deleteNode = function () {
+ var id = this[expando];
+ var nodeDeleted = false;
+ if (id && data[id]) {
+ nodeDeleted = true;
+ delete data[id];
+ }
+ return nodeDeleted;
+ };
+ module.exports = {
+ _data: data,
+ getCid: function () {
+ return this[expando];
+ },
+ cid: function () {
+ return this[expando] || (this[expando] = ++uuid);
+ },
+ expando: expando,
+ get: function (key) {
+ var id = this[expando], store = id && data[id];
+ return key === undefined ? store || setData(this) : store && store[key];
+ },
+ set: setData,
+ clean: function (prop) {
+ var id = this[expando];
+ var itemData = data[id];
+ if (itemData && itemData[prop]) {
+ delete itemData[prop];
+ }
+ if (isEmptyObject(itemData)) {
+ deleteNode.call(this);
+ }
+ },
+ delete: deleteNode
+ };
+});
+/*can-util@3.3.3#dom/mutation-observer/mutation-observer*/
+define('can-util/dom/mutation-observer/mutation-observer', function (require, exports, module) {
+ (function (global) {
+ var global = require('can-util/js/global/global')();
+ var setMutationObserver;
+ module.exports = function (setMO) {
+ if (setMO !== undefined) {
+ setMutationObserver = setMO;
+ }
+ return setMutationObserver !== undefined ? setMutationObserver : global.MutationObserver || global.WebKitMutationObserver || global.MozMutationObserver;
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/is-array-like/is-array-like*/
+define('can-util/js/is-array-like/is-array-like', function (require, exports, module) {
+ function isArrayLike(obj) {
+ var type = typeof obj;
+ if (type === 'string') {
+ return true;
+ } else if (type === 'number') {
+ return false;
+ }
+ var length = obj && type !== 'boolean' && typeof obj !== 'number' && 'length' in obj && obj.length;
+ return typeof obj !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj);
+ }
+ module.exports = isArrayLike;
+});
+/*can-types@1.0.4#can-types*/
+define('can-types', function (require, exports, module) {
+ var namespace = require('can-namespace');
+ var types = {
+ isMapLike: function () {
+ return false;
+ },
+ isListLike: function () {
+ return false;
+ },
+ isPromise: function (obj) {
+ return obj instanceof Promise || Object.prototype.toString.call(obj) === '[object Promise]';
+ },
+ isConstructor: function (func) {
+ if (typeof func !== 'function') {
+ return false;
+ }
+ for (var prop in func.prototype) {
+ return true;
+ }
+ return false;
+ },
+ isCallableForValue: function (obj) {
+ return typeof obj === 'function' && !types.isConstructor(obj);
+ },
+ isCompute: function (obj) {
+ return obj && obj.isComputed;
+ },
+ iterator: typeof Symbol === 'function' && Symbol.iterator || '@@iterator',
+ DefaultMap: null,
+ DefaultList: null,
+ queueTask: function (task) {
+ var args = task[2] || [];
+ task[0].apply(task[1], args);
+ },
+ wrapElement: function (element) {
+ return element;
+ },
+ unwrapElement: function (element) {
+ return element;
+ }
+ };
+ if (namespace.types) {
+ throw new Error('You can\'t have two versions of can-types, check your dependencies');
+ } else {
+ module.exports = namespace.types = types;
+ }
+});
+/*can-util@3.3.3#js/is-iterable/is-iterable*/
+define('can-util/js/is-iterable/is-iterable', function (require, exports, module) {
+ var types = require('can-types');
+ module.exports = function (obj) {
+ return obj && !!obj[types.iterator];
+ };
+});
+/*can-util@3.3.3#js/each/each*/
+define('can-util/js/each/each', function (require, exports, module) {
+ var isArrayLike = require('can-util/js/is-array-like/is-array-like');
+ var has = Object.prototype.hasOwnProperty;
+ var isIterable = require('can-util/js/is-iterable/is-iterable');
+ var types = require('can-types');
+ function each(elements, callback, context) {
+ var i = 0, key, len, item;
+ if (elements) {
+ if (isArrayLike(elements)) {
+ for (len = elements.length; i < len; i++) {
+ item = elements[i];
+ if (callback.call(context || item, item, i, elements) === false) {
+ break;
+ }
+ }
+ } else if (isIterable(elements)) {
+ var iter = elements[types.iterator]();
+ var res, value;
+ while (!(res = iter.next()).done) {
+ value = res.value;
+ callback.call(context || elements, Array.isArray(value) ? value[1] : value, value[0]);
+ }
+ } else if (typeof elements === 'object') {
+ for (key in elements) {
+ if (has.call(elements, key) && callback.call(context || elements[key], elements[key], key, elements) === false) {
+ break;
+ }
+ }
+ }
+ }
+ return elements;
+ }
+ module.exports = each;
+});
+/*can-cid@1.0.3#can-cid*/
+define('can-cid', function (require, exports, module) {
+ var namespace = require('can-namespace');
+ var _cid = 0;
+ var cid = function (object, name) {
+ if (!object._cid) {
+ _cid++;
+ object._cid = (name || '') + _cid;
+ }
+ return object._cid;
+ };
+ if (namespace.cid) {
+ throw new Error('You can\'t have two versions of can-cid, check your dependencies');
+ } else {
+ module.exports = namespace.cid = cid;
+ }
+});
+/*can-util@3.3.3#js/cid/get-cid*/
+define('can-util/js/cid/get-cid', function (require, exports, module) {
+ var CID = require('can-cid');
+ var domDataCore = require('can-util/dom/data/core');
+ module.exports = function (obj) {
+ if (typeof obj.nodeType === 'number') {
+ return domDataCore.cid.call(obj);
+ } else {
+ var type = typeof obj;
+ var isObject = type !== null && (type === 'object' || type === 'function');
+ return type + ':' + (isObject ? CID(obj) : obj);
+ }
+ };
+});
+/*can-util@3.3.3#js/cid-set/cid-set*/
+define('can-util/js/cid-set/cid-set', function (require, exports, module) {
+ (function (global) {
+ var GLOBAL = require('can-util/js/global/global');
+ var each = require('can-util/js/each/each');
+ var getCID = require('can-util/js/cid/get-cid');
+ var CIDSet;
+ if (GLOBAL().Set) {
+ CIDSet = GLOBAL().Set;
+ } else {
+ var CIDSet = function () {
+ this.values = {};
+ };
+ CIDSet.prototype.add = function (value) {
+ this.values[getCID(value)] = value;
+ };
+ CIDSet.prototype['delete'] = function (key) {
+ var has = getCID(key) in this.values;
+ if (has) {
+ delete this.values[getCID(key)];
+ }
+ return has;
+ };
+ CIDSet.prototype.forEach = function (cb, thisArg) {
+ each(this.values, cb, thisArg);
+ };
+ CIDSet.prototype.has = function (value) {
+ return getCID(value) in this.values;
+ };
+ CIDSet.prototype.clear = function (key) {
+ return this.values = {};
+ };
+ Object.defineProperty(CIDSet.prototype, 'size', {
+ get: function () {
+ var size = 0;
+ each(this.values, function () {
+ size++;
+ });
+ return size;
+ }
+ });
+ }
+ module.exports = CIDSet;
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/make-array/make-array*/
+define('can-util/js/make-array/make-array', function (require, exports, module) {
+ var each = require('can-util/js/each/each');
+ var isArrayLike = require('can-util/js/is-array-like/is-array-like');
+ function makeArray(element) {
+ var ret = [];
+ if (isArrayLike(element)) {
+ each(element, function (a, i) {
+ ret[i] = a;
+ });
+ } else if (element === 0 || element) {
+ ret.push(element);
+ }
+ return ret;
+ }
+ module.exports = makeArray;
+});
+/*can-util@3.3.3#js/is-container/is-container*/
+define('can-util/js/is-container/is-container', function (require, exports, module) {
+ module.exports = function (current) {
+ return /^f|^o/.test(typeof current);
+ };
+});
+/*can-util@3.3.3#js/get/get*/
+define('can-util/js/get/get', function (require, exports, module) {
+ var isContainer = require('can-util/js/is-container/is-container');
+ function get(obj, name) {
+ var parts = typeof name !== 'undefined' ? (name + '').replace(/\[/g, '.').replace(/]/g, '').split('.') : [], length = parts.length, current, i, container;
+ if (!length) {
+ return obj;
+ }
+ current = obj;
+ for (i = 0; i < length && isContainer(current); i++) {
+ container = current;
+ current = container[parts[i]];
+ }
+ return current;
+ }
+ module.exports = get;
+});
+/*can-util@3.3.3#js/log/log*/
+define('can-util/js/log/log', function (require, exports, module) {
+ exports.warnTimeout = 5000;
+ exports.logLevel = 0;
+ exports.warn = function (out) {
+ var ll = this.logLevel;
+ if (ll < 2) {
+ Array.prototype.unshift.call(arguments, 'WARN:');
+ if (typeof console !== 'undefined' && console.warn) {
+ this._logger('warn', Array.prototype.slice.call(arguments));
+ } else if (typeof console !== 'undefined' && console.log) {
+ this._logger('log', Array.prototype.slice.call(arguments));
+ } else if (window && window.opera && window.opera.postError) {
+ window.opera.postError('CanJS WARNING: ' + out);
+ }
+ }
+ };
+ exports.log = function (out) {
+ var ll = this.logLevel;
+ if (ll < 1) {
+ if (typeof console !== 'undefined' && console.log) {
+ Array.prototype.unshift.call(arguments, 'INFO:');
+ this._logger('log', Array.prototype.slice.call(arguments));
+ } else if (window && window.opera && window.opera.postError) {
+ window.opera.postError('CanJS INFO: ' + out);
+ }
+ }
+ };
+ exports.error = function (out) {
+ var ll = this.logLevel;
+ if (ll < 1) {
+ if (typeof console !== 'undefined' && console.error) {
+ Array.prototype.unshift.call(arguments, 'ERROR:');
+ this._logger('error', Array.prototype.slice.call(arguments));
+ } else if (window && window.opera && window.opera.postError) {
+ window.opera.postError('ERROR: ' + out);
+ }
+ }
+ };
+ exports._logger = function (type, arr) {
+ try {
+ console[type].apply(console, arr);
+ } catch (e) {
+ console[type](arr);
+ }
+ };
+});
+/*can-util@3.3.3#js/dev/dev*/
+define('can-util/js/dev/dev', function (require, exports, module) {
+ var canLog = require('can-util/js/log/log');
+ module.exports = {
+ warnTimeout: 5000,
+ logLevel: 0,
+ warn: function () {
+ },
+ log: function () {
+ },
+ _logger: canLog._logger
+ };
+});
+/*can-util@3.3.3#js/string/string*/
+define('can-util/js/string/string', function (require, exports, module) {
+ var get = require('can-util/js/get/get');
+ var isContainer = require('can-util/js/is-container/is-container');
+ var canDev = require('can-util/js/dev/dev');
+ var isArray = require('can-util/js/is-array/is-array');
+ var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, convertBadValues = function (content) {
+ var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN';
+ return '' + (isInvalid ? '' : content);
+ }, deleteAtPath = function (data, path) {
+ var parts = path ? path.replace(/\[/g, '.').replace(/]/g, '').split('.') : [];
+ var current = data;
+ for (var i = 0; i < parts.length - 1; i++) {
+ if (current) {
+ current = current[parts[i]];
+ }
+ }
+ if (current) {
+ delete current[parts[parts.length - 1]];
+ }
+ };
+ var string = {
+ esc: function (content) {
+ return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, ''');
+ },
+ getObject: function (name, roots) {
+ roots = isArray(roots) ? roots : [roots || window];
+ var result, l = roots.length;
+ for (var i = 0; i < l; i++) {
+ result = get(roots[i], name);
+ if (result) {
+ return result;
+ }
+ }
+ },
+ capitalize: function (s, cache) {
+ return s.charAt(0).toUpperCase() + s.slice(1);
+ },
+ camelize: function (str) {
+ return convertBadValues(str).replace(strHyphenMatch, function (match, chr) {
+ return chr ? chr.toUpperCase() : '';
+ });
+ },
+ hyphenate: function (str) {
+ return convertBadValues(str).replace(strCamelMatch, function (str, offset) {
+ return str.charAt(0) + '-' + str.charAt(1).toLowerCase();
+ });
+ },
+ underscore: function (s) {
+ return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase();
+ },
+ sub: function (str, data, remove) {
+ var obs = [];
+ str = str || '';
+ obs.push(str.replace(strReplacer, function (whole, inside) {
+ var ob = get(data, inside);
+ if (remove === true) {
+ deleteAtPath(data, inside);
+ }
+ if (ob === undefined || ob === null) {
+ obs = null;
+ return '';
+ }
+ if (isContainer(ob) && obs) {
+ obs.push(ob);
+ return '';
+ }
+ return '' + ob;
+ }));
+ return obs === null ? obs : obs.length <= 1 ? obs[0] : obs;
+ },
+ replacer: strReplacer,
+ undHash: strUndHash
+ };
+ module.exports = string;
+});
+/*can-util@3.3.3#dom/mutation-observer/document/document*/
+define('can-util/dom/mutation-observer/document/document', function (require, exports, module) {
+ (function (global) {
+ var getDocument = require('can-util/dom/document/document');
+ var domDataCore = require('can-util/dom/data/core');
+ var MUTATION_OBSERVER = require('can-util/dom/mutation-observer/mutation-observer');
+ var each = require('can-util/js/each/each');
+ var CIDStore = require('can-util/js/cid-set/cid-set');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var string = require('can-util/js/string/string');
+ var dispatchIfListening = function (mutatedNode, nodes, dispatched) {
+ if (dispatched.has(mutatedNode)) {
+ return true;
+ }
+ dispatched.add(mutatedNode);
+ if (nodes.name === 'removedNodes') {
+ var documentElement = getDocument().documentElement;
+ if (documentElement.contains(mutatedNode)) {
+ return;
+ }
+ }
+ nodes.handlers.forEach(function (handler) {
+ handler(mutatedNode);
+ });
+ nodes.afterHandlers.forEach(function (handler) {
+ handler(mutatedNode);
+ });
+ };
+ var mutationObserverDocument = {
+ add: function (handler) {
+ var MO = MUTATION_OBSERVER();
+ if (MO) {
+ var documentElement = getDocument().documentElement;
+ var globalObserverData = domDataCore.get.call(documentElement, 'globalObserverData');
+ if (!globalObserverData) {
+ var observer = new MO(function (mutations) {
+ globalObserverData.handlers.forEach(function (handler) {
+ handler(mutations);
+ });
+ });
+ observer.observe(documentElement, {
+ childList: true,
+ subtree: true
+ });
+ globalObserverData = {
+ observer: observer,
+ handlers: []
+ };
+ domDataCore.set.call(documentElement, 'globalObserverData', globalObserverData);
+ }
+ globalObserverData.handlers.push(handler);
+ }
+ },
+ remove: function (handler) {
+ var documentElement = getDocument().documentElement;
+ var globalObserverData = domDataCore.get.call(documentElement, 'globalObserverData');
+ if (globalObserverData) {
+ var index = globalObserverData.handlers.indexOf(handler);
+ if (index >= 0) {
+ globalObserverData.handlers.splice(index, 1);
+ }
+ if (globalObserverData.handlers.length === 0) {
+ globalObserverData.observer.disconnect();
+ domDataCore.clean.call(documentElement, 'globalObserverData');
+ }
+ }
+ }
+ };
+ var makeMutationMethods = function (name) {
+ var mutationName = name.toLowerCase() + 'Nodes';
+ var getMutationData = function () {
+ var documentElement = getDocument().documentElement;
+ var mutationData = domDataCore.get.call(documentElement, mutationName + 'MutationData');
+ if (!mutationData) {
+ mutationData = {
+ name: mutationName,
+ handlers: [],
+ afterHandlers: [],
+ hander: null
+ };
+ if (MUTATION_OBSERVER()) {
+ domDataCore.set.call(documentElement, mutationName + 'MutationData', mutationData);
+ }
+ }
+ return mutationData;
+ };
+ var setup = function () {
+ var mutationData = getMutationData();
+ if (mutationData.handlers.length === 0 || mutationData.afterHandlers.length === 0) {
+ mutationData.handler = function (mutations) {
+ var dispatched = new CIDStore();
+ mutations.forEach(function (mutation) {
+ each(mutation[mutationName], function (mutatedNode) {
+ var children = mutatedNode.getElementsByTagName && makeArray(mutatedNode.getElementsByTagName('*'));
+ var alreadyChecked = dispatchIfListening(mutatedNode, mutationData, dispatched);
+ if (children && !alreadyChecked) {
+ for (var j = 0, child; (child = children[j]) !== undefined; j++) {
+ dispatchIfListening(child, mutationData, dispatched);
+ }
+ }
+ });
+ });
+ };
+ this.add(mutationData.handler);
+ }
+ return mutationData;
+ };
+ var teardown = function () {
+ var documentElement = getDocument().documentElement;
+ var mutationData = getMutationData();
+ if (mutationData.handlers.length === 0 && mutationData.afterHandlers.length === 0) {
+ this.remove(mutationData.handler);
+ domDataCore.clean.call(documentElement, mutationName + 'MutationData');
+ }
+ };
+ var createOnOffHandlers = function (name, handlerList) {
+ mutationObserverDocument['on' + name] = function (handler) {
+ var mutationData = setup.call(this);
+ mutationData[handlerList].push(handler);
+ };
+ mutationObserverDocument['off' + name] = function (handler) {
+ var mutationData = getMutationData();
+ var index = mutationData[handlerList].indexOf(handler);
+ if (index >= 0) {
+ mutationData[handlerList].splice(index, 1);
+ }
+ teardown.call(this);
+ };
+ };
+ var createHandlers = function (name) {
+ createOnOffHandlers(name, 'handlers');
+ createOnOffHandlers('After' + name, 'afterHandlers');
+ };
+ createHandlers(string.capitalize(mutationName));
+ };
+ makeMutationMethods('added');
+ makeMutationMethods('removed');
+ module.exports = mutationObserverDocument;
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#dom/data/data*/
+define('can-util/dom/data/data', function (require, exports, module) {
+ var domDataCore = require('can-util/dom/data/core');
+ var mutationDocument = require('can-util/dom/mutation-observer/document/document');
+ var deleteNode = function () {
+ return domDataCore.delete.call(this);
+ };
+ var elementSetCount = 0;
+ var cleanupDomData = function (node) {
+ elementSetCount -= deleteNode.call(node) ? 1 : 0;
+ if (elementSetCount === 0) {
+ mutationDocument.offAfterRemovedNodes(cleanupDomData);
+ }
+ };
+ module.exports = {
+ getCid: domDataCore.getCid,
+ cid: domDataCore.cid,
+ expando: domDataCore.expando,
+ clean: domDataCore.clean,
+ get: domDataCore.get,
+ set: function (name, value) {
+ if (elementSetCount === 0) {
+ mutationDocument.onAfterRemovedNodes(cleanupDomData);
+ }
+ elementSetCount += domDataCore.set.call(this, name, value) ? 1 : 0;
+ },
+ delete: deleteNode
+ };
+});
+/*can-util@3.3.3#dom/contains/contains*/
+define('can-util/dom/contains/contains', function (require, exports, module) {
+ module.exports = function (child) {
+ return this.contains(child);
+ };
+});
+/*can-util@3.3.3#dom/events/events*/
+define('can-util/dom/events/events', function (require, exports, module) {
+ var assign = require('can-util/js/assign/assign');
+ var _document = require('can-util/dom/document/document');
+ var isPlainObject = require('can-util/js/is-plain-object/is-plain-object');
+ var fixSyntheticEventsOnDisabled = false;
+ function isDispatchingOnDisabled(element, ev) {
+ var isInsertedOrRemoved = isPlainObject(ev) ? ev.type === 'inserted' || ev.type === 'removed' : ev === 'inserted' || ev === 'removed';
+ var isDisabled = !!element.disabled;
+ return isInsertedOrRemoved && isDisabled;
+ }
+ module.exports = {
+ addEventListener: function () {
+ this.addEventListener.apply(this, arguments);
+ },
+ removeEventListener: function () {
+ this.removeEventListener.apply(this, arguments);
+ },
+ canAddEventListener: function () {
+ return this.nodeName && (this.nodeType === 1 || this.nodeType === 9) || this === window;
+ },
+ dispatch: function (event, args, bubbles) {
+ var doc = _document();
+ var ret;
+ var dispatchingOnDisabled = fixSyntheticEventsOnDisabled && isDispatchingOnDisabled(this, event);
+ var ev = doc.createEvent('HTMLEvents');
+ var isString = typeof event === 'string';
+ ev.initEvent(isString ? event : event.type, bubbles === undefined ? true : bubbles, false);
+ if (!isString) {
+ assign(ev, event);
+ }
+ ev.args = args;
+ if (dispatchingOnDisabled) {
+ this.disabled = false;
+ }
+ ret = this.dispatchEvent(ev);
+ if (dispatchingOnDisabled) {
+ this.disabled = true;
+ }
+ return ret;
+ }
+ };
+ (function () {
+ var input = document.createElement('input');
+ input.disabled = true;
+ var timer = setTimeout(function () {
+ fixSyntheticEventsOnDisabled = true;
+ }, 50);
+ module.exports.addEventListener.call(input, 'foo', function () {
+ clearTimeout(timer);
+ });
+ try {
+ module.exports.dispatch.call(input, 'foo', [], false);
+ } catch (e) {
+ clearTimeout(timer);
+ fixSyntheticEventsOnDisabled = true;
+ }
+ }());
+});
+/*can-util@3.3.3#dom/dispatch/dispatch*/
+define('can-util/dom/dispatch/dispatch', function (require, exports, module) {
+ var domEvents = require('can-util/dom/events/events');
+ module.exports = function () {
+ return domEvents.dispatch.apply(this, arguments);
+ };
+});
+/*can-util@3.3.3#js/diff/diff*/
+define('can-util/js/diff/diff', function (require, exports, module) {
+ var slice = [].slice;
+ var defaultIdentity = function (a, b) {
+ return a === b;
+ };
+ module.exports = exports = function (oldList, newList, identity) {
+ identity = identity || defaultIdentity;
+ var oldIndex = 0, newIndex = 0, oldLength = oldList.length, newLength = newList.length, patches = [];
+ while (oldIndex < oldLength && newIndex < newLength) {
+ var oldItem = oldList[oldIndex], newItem = newList[newIndex];
+ if (identity(oldItem, newItem)) {
+ oldIndex++;
+ newIndex++;
+ continue;
+ }
+ if (newIndex + 1 < newLength && identity(oldItem, newList[newIndex + 1])) {
+ patches.push({
+ index: newIndex,
+ deleteCount: 0,
+ insert: [newList[newIndex]]
+ });
+ oldIndex++;
+ newIndex += 2;
+ continue;
+ } else if (oldIndex + 1 < oldLength && identity(oldList[oldIndex + 1], newItem)) {
+ patches.push({
+ index: newIndex,
+ deleteCount: 1,
+ insert: []
+ });
+ oldIndex += 2;
+ newIndex++;
+ continue;
+ } else {
+ patches.push({
+ index: newIndex,
+ deleteCount: oldLength - oldIndex,
+ insert: slice.call(newList, newIndex)
+ });
+ return patches;
+ }
+ }
+ if (newIndex === newLength && oldIndex === oldLength) {
+ return patches;
+ }
+ patches.push({
+ index: newIndex,
+ deleteCount: oldLength - oldIndex,
+ insert: slice.call(newList, newIndex)
+ });
+ return patches;
+ };
+});
+/*can-util@3.3.3#dom/events/attributes/attributes*/
+define('can-util/dom/events/attributes/attributes', function (require, exports, module) {
+ (function (global) {
+ var events = require('can-util/dom/events/events');
+ var isOfGlobalDocument = require('can-util/dom/is-of-global-document/is-of-global-document');
+ var domData = require('can-util/dom/data/data');
+ var getMutationObserver = require('can-util/dom/mutation-observer/mutation-observer');
+ var assign = require('can-util/js/assign/assign');
+ var domDispatch = require('can-util/dom/dispatch/dispatch');
+ var originalAdd = events.addEventListener, originalRemove = events.removeEventListener;
+ events.addEventListener = function (eventName) {
+ if (eventName === 'attributes') {
+ var MutationObserver = getMutationObserver();
+ if (isOfGlobalDocument(this) && MutationObserver) {
+ var self = this;
+ var observer = new MutationObserver(function (mutations) {
+ mutations.forEach(function (mutation) {
+ var copy = assign({}, mutation);
+ domDispatch.call(self, copy, [], false);
+ });
+ });
+ observer.observe(this, {
+ attributes: true,
+ attributeOldValue: true
+ });
+ domData.set.call(this, 'canAttributesObserver', observer);
+ } else {
+ domData.set.call(this, 'canHasAttributesBindings', true);
+ }
+ }
+ return originalAdd.apply(this, arguments);
+ };
+ events.removeEventListener = function (eventName) {
+ if (eventName === 'attributes') {
+ var MutationObserver = getMutationObserver();
+ var observer;
+ if (isOfGlobalDocument(this) && MutationObserver) {
+ observer = domData.get.call(this, 'canAttributesObserver');
+ if (observer && observer.disconnect) {
+ observer.disconnect();
+ domData.clean.call(this, 'canAttributesObserver');
+ }
+ } else {
+ domData.clean.call(this, 'canHasAttributesBindings');
+ }
+ }
+ return originalRemove.apply(this, arguments);
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#dom/attr/attr*/
+define('can-util/dom/attr/attr', function (require, exports, module) {
+ (function (global) {
+ var setImmediate = require('can-util/js/set-immediate/set-immediate');
+ var getDocument = require('can-util/dom/document/document');
+ var global = require('can-util/js/global/global')();
+ var isOfGlobalDocument = require('can-util/dom/is-of-global-document/is-of-global-document');
+ var setData = require('can-util/dom/data/data');
+ var domContains = require('can-util/dom/contains/contains');
+ var domEvents = require('can-util/dom/events/events');
+ var domDispatch = require('can-util/dom/dispatch/dispatch');
+ var MUTATION_OBSERVER = require('can-util/dom/mutation-observer/mutation-observer');
+ var each = require('can-util/js/each/each');
+ var types = require('can-types');
+ var diff = require('can-util/js/diff/diff');
+ require('can-util/dom/events/attributes/attributes');
+ var namespaces = { 'xlink': 'http://www.w3.org/1999/xlink' };
+ var formElements = {
+ 'INPUT': true,
+ 'TEXTAREA': true,
+ 'SELECT': true
+ }, toString = function (value) {
+ if (value == null) {
+ return '';
+ } else {
+ return '' + value;
+ }
+ }, isSVG = function (el) {
+ return el.namespaceURI === 'http://www.w3.org/2000/svg';
+ }, truthy = function () {
+ return true;
+ }, getSpecialTest = function (special) {
+ return special && special.test || truthy;
+ }, propProp = function (prop, obj) {
+ obj = obj || {};
+ obj.get = function () {
+ return this[prop];
+ };
+ obj.set = function (value) {
+ if (this[prop] !== value) {
+ this[prop] = value;
+ }
+ return value;
+ };
+ return obj;
+ }, booleanProp = function (prop) {
+ return {
+ isBoolean: true,
+ set: function (value) {
+ if (prop in this) {
+ this[prop] = value !== false;
+ } else {
+ this.setAttribute(prop, '');
+ }
+ },
+ remove: function () {
+ this[prop] = false;
+ }
+ };
+ }, setupMO = function (el, callback) {
+ var attrMO = setData.get.call(el, 'attrMO');
+ if (!attrMO) {
+ var onMutation = function () {
+ callback.call(el);
+ };
+ var MO = MUTATION_OBSERVER();
+ if (MO) {
+ var observer = new MO(onMutation);
+ observer.observe(el, {
+ childList: true,
+ subtree: true
+ });
+ setData.set.call(el, 'attrMO', observer);
+ } else {
+ setData.set.call(el, 'attrMO', true);
+ setData.set.call(el, 'canBindingCallback', { onMutation: onMutation });
+ }
+ }
+ }, setChildOptions = function (el, value) {
+ if (value != null) {
+ var child = el.firstChild, hasSelected = false;
+ while (child) {
+ if (child.nodeName === 'OPTION') {
+ if (value === child.value) {
+ hasSelected = child.selected = true;
+ break;
+ }
+ }
+ child = child.nextSibling;
+ }
+ if (!hasSelected) {
+ el.selectedIndex = -1;
+ }
+ } else {
+ el.selectedIndex = -1;
+ }
+ }, setChildOptionsOnChange = function (select, aEL) {
+ var handler = setData.get.call(select, 'attrSetChildOptions');
+ if (handler) {
+ return Function.prototype;
+ }
+ handler = function () {
+ setChildOptions(select, select.value);
+ };
+ setData.set.call(select, 'attrSetChildOptions', handler);
+ aEL.call(select, 'change', handler);
+ return function (rEL) {
+ setData.clean.call(select, 'attrSetChildOptions');
+ rEL.call(select, 'change', handler);
+ };
+ }, attr = {
+ special: {
+ checked: {
+ get: function () {
+ return this.checked;
+ },
+ set: function (val) {
+ var notFalse = !!val || val === '' || arguments.length === 0;
+ this.checked = notFalse;
+ if (notFalse && this.type === 'radio') {
+ this.defaultChecked = true;
+ }
+ return val;
+ },
+ remove: function () {
+ this.checked = false;
+ },
+ test: function () {
+ return this.nodeName === 'INPUT';
+ }
+ },
+ 'class': {
+ get: function () {
+ if (isSVG(this)) {
+ return this.getAttribute('class');
+ }
+ return this.className;
+ },
+ set: function (val) {
+ val = val || '';
+ if (isSVG(this)) {
+ this.setAttribute('class', '' + val);
+ } else {
+ this.className = val;
+ }
+ return val;
+ }
+ },
+ disabled: booleanProp('disabled'),
+ focused: {
+ get: function () {
+ return this === document.activeElement;
+ },
+ set: function (val) {
+ var cur = attr.get(this, 'focused');
+ if (cur !== val) {
+ var element = this;
+ types.queueTask([
+ function () {
+ if (val) {
+ element.focus();
+ } else {
+ element.blur();
+ }
+ },
+ this,
+ []
+ ]);
+ }
+ return !!val;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ aEL.call(this, 'focus', handler);
+ aEL.call(this, 'blur', handler);
+ return function (rEL) {
+ rEL.call(this, 'focus', handler);
+ rEL.call(this, 'blur', handler);
+ };
+ },
+ test: function () {
+ return this.nodeName === 'INPUT';
+ }
+ },
+ 'for': propProp('htmlFor'),
+ innertext: propProp('innerText'),
+ innerhtml: propProp('innerHTML'),
+ innerHTML: propProp('innerHTML', {
+ addEventListener: function (eventName, handler, aEL) {
+ var handlers = [];
+ var el = this;
+ each([
+ 'change',
+ 'blur'
+ ], function (eventName) {
+ var localHandler = function () {
+ handler.apply(this, arguments);
+ };
+ domEvents.addEventListener.call(el, eventName, localHandler);
+ handlers.push([
+ eventName,
+ localHandler
+ ]);
+ });
+ return function (rEL) {
+ each(handlers, function (info) {
+ rEL.call(el, info[0], info[1]);
+ });
+ };
+ }
+ }),
+ required: booleanProp('required'),
+ readonly: booleanProp('readOnly'),
+ selected: {
+ get: function () {
+ return this.selected;
+ },
+ set: function (val) {
+ val = !!val;
+ setData.set.call(this, 'lastSetValue', val);
+ return this.selected = val;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ var option = this;
+ var select = this.parentNode;
+ var lastVal = option.selected;
+ var localHandler = function (changeEvent) {
+ var curVal = option.selected;
+ lastVal = setData.get.call(option, 'lastSetValue') || lastVal;
+ if (curVal !== lastVal) {
+ lastVal = curVal;
+ domDispatch.call(option, eventName);
+ }
+ };
+ var removeChangeHandler = setChildOptionsOnChange(select, aEL);
+ domEvents.addEventListener.call(select, 'change', localHandler);
+ aEL.call(option, eventName, handler);
+ return function (rEL) {
+ removeChangeHandler(rEL);
+ domEvents.removeEventListener.call(select, 'change', localHandler);
+ rEL.call(option, eventName, handler);
+ };
+ },
+ test: function () {
+ return this.nodeName === 'OPTION' && this.parentNode && this.parentNode.nodeName === 'SELECT';
+ }
+ },
+ src: {
+ set: function (val) {
+ if (val == null || val === '') {
+ this.removeAttribute('src');
+ return null;
+ } else {
+ this.setAttribute('src', val);
+ return val;
+ }
+ }
+ },
+ style: {
+ set: function () {
+ var el = global.document && getDocument().createElement('div');
+ if (el && el.style && 'cssText' in el.style) {
+ return function (val) {
+ return this.style.cssText = val || '';
+ };
+ } else {
+ return function (val) {
+ return this.setAttribute('style', val);
+ };
+ }
+ }()
+ },
+ textcontent: propProp('textContent'),
+ value: {
+ get: function () {
+ var value = this.value;
+ if (this.nodeName === 'SELECT') {
+ if ('selectedIndex' in this && this.selectedIndex === -1) {
+ value = undefined;
+ }
+ }
+ return value;
+ },
+ set: function (value) {
+ var nodeName = this.nodeName.toLowerCase();
+ if (nodeName === 'input') {
+ value = toString(value);
+ }
+ if (this.value !== value || nodeName === 'option') {
+ this.value = value;
+ }
+ if (attr.defaultValue[nodeName]) {
+ this.defaultValue = value;
+ }
+ if (nodeName === 'select') {
+ setData.set.call(this, 'attrValueLastVal', value);
+ setChildOptions(this, value === null ? value : this.value);
+ var docEl = this.ownerDocument.documentElement;
+ if (!domContains.call(docEl, this)) {
+ var select = this;
+ var initialSetHandler = function () {
+ domEvents.removeEventListener.call(select, 'inserted', initialSetHandler);
+ setChildOptions(select, value === null ? value : select.value);
+ };
+ domEvents.addEventListener.call(this, 'inserted', initialSetHandler);
+ }
+ setupMO(this, function () {
+ var value = setData.get.call(this, 'attrValueLastVal');
+ attr.set(this, 'value', value);
+ domDispatch.call(this, 'change');
+ });
+ }
+ return value;
+ },
+ test: function () {
+ return formElements[this.nodeName];
+ }
+ },
+ values: {
+ get: function () {
+ var values = [];
+ var child = this.firstChild;
+ while (child) {
+ if (child.nodeName === 'OPTION' && child.selected) {
+ values.push(child.value);
+ }
+ child = child.nextSibling;
+ }
+ return values;
+ },
+ set: function (values) {
+ values = values || [];
+ var child = this.firstChild;
+ while (child) {
+ if (child.nodeName === 'OPTION') {
+ child.selected = values.indexOf(child.value) !== -1;
+ }
+ child = child.nextSibling;
+ }
+ setData.set.call(this, 'stickyValues', attr.get(this, 'values'));
+ setupMO(this, function () {
+ var previousValues = setData.get.call(this, 'stickyValues');
+ attr.set(this, 'values', previousValues);
+ var currentValues = setData.get.call(this, 'stickyValues');
+ var changes = diff(previousValues.slice().sort(), currentValues.slice().sort());
+ if (changes.length) {
+ domDispatch.call(this, 'values');
+ }
+ });
+ return values;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ var localHandler = function () {
+ domDispatch.call(this, 'values');
+ };
+ domEvents.addEventListener.call(this, 'change', localHandler);
+ aEL.call(this, eventName, handler);
+ return function (rEL) {
+ domEvents.removeEventListener.call(this, 'change', localHandler);
+ rEL.call(this, eventName, handler);
+ };
+ }
+ }
+ },
+ defaultValue: {
+ input: true,
+ textarea: true
+ },
+ setAttrOrProp: function (el, attrName, val) {
+ attrName = attrName.toLowerCase();
+ var special = attr.special[attrName];
+ if (special && special.isBoolean && !val) {
+ this.remove(el, attrName);
+ } else {
+ this.set(el, attrName, val);
+ }
+ },
+ set: function (el, attrName, val) {
+ var usingMutationObserver = isOfGlobalDocument(el) && MUTATION_OBSERVER();
+ attrName = attrName.toLowerCase();
+ var oldValue;
+ if (!usingMutationObserver) {
+ oldValue = attr.get(el, attrName);
+ }
+ var newValue;
+ var special = attr.special[attrName];
+ var setter = special && special.set;
+ var test = getSpecialTest(special);
+ if (typeof setter === 'function' && test.call(el)) {
+ if (arguments.length === 2) {
+ newValue = setter.call(el);
+ } else {
+ newValue = setter.call(el, val);
+ }
+ } else {
+ attr.setAttribute(el, attrName, val);
+ }
+ if (!usingMutationObserver && newValue !== oldValue) {
+ attr.trigger(el, attrName, oldValue);
+ }
+ },
+ setSelectValue: function (el, value) {
+ attr.set(el, 'value', value);
+ },
+ setAttribute: function () {
+ var doc = getDocument();
+ if (doc && document.createAttribute) {
+ try {
+ doc.createAttribute('{}');
+ } catch (e) {
+ var invalidNodes = {}, attributeDummy = document.createElement('div');
+ return function (el, attrName, val) {
+ var first = attrName.charAt(0), cachedNode, node, attr;
+ if ((first === '{' || first === '(' || first === '*') && el.setAttributeNode) {
+ cachedNode = invalidNodes[attrName];
+ if (!cachedNode) {
+ attributeDummy.innerHTML = '';
+ cachedNode = invalidNodes[attrName] = attributeDummy.childNodes[0].attributes[0];
+ }
+ node = cachedNode.cloneNode();
+ node.value = val;
+ el.setAttributeNode(node);
+ } else {
+ attr = attrName.split(':');
+ if (attr.length !== 1) {
+ el.setAttributeNS(namespaces[attr[0]], attrName, val);
+ } else {
+ el.setAttribute(attrName, val);
+ }
+ }
+ };
+ }
+ }
+ return function (el, attrName, val) {
+ el.setAttribute(attrName, val);
+ };
+ }(),
+ trigger: function (el, attrName, oldValue) {
+ if (setData.get.call(el, 'canHasAttributesBindings')) {
+ attrName = attrName.toLowerCase();
+ return setImmediate(function () {
+ domDispatch.call(el, {
+ type: 'attributes',
+ attributeName: attrName,
+ target: el,
+ oldValue: oldValue,
+ bubbles: false
+ }, []);
+ });
+ }
+ },
+ get: function (el, attrName) {
+ attrName = attrName.toLowerCase();
+ var special = attr.special[attrName];
+ var getter = special && special.get;
+ var test = getSpecialTest(special);
+ if (typeof getter === 'function' && test.call(el)) {
+ return getter.call(el);
+ } else {
+ return el.getAttribute(attrName);
+ }
+ },
+ remove: function (el, attrName) {
+ attrName = attrName.toLowerCase();
+ var oldValue;
+ if (!MUTATION_OBSERVER()) {
+ oldValue = attr.get(el, attrName);
+ }
+ var special = attr.special[attrName];
+ var setter = special && special.set;
+ var remover = special && special.remove;
+ var test = getSpecialTest(special);
+ if (typeof remover === 'function' && test.call(el)) {
+ remover.call(el);
+ } else if (typeof setter === 'function' && test.call(el)) {
+ setter.call(el, undefined);
+ } else {
+ el.removeAttribute(attrName);
+ }
+ if (!MUTATION_OBSERVER() && oldValue != null) {
+ attr.trigger(el, attrName, oldValue);
+ }
+ },
+ has: function () {
+ var el = getDocument() && document.createElement('div');
+ if (el && el.hasAttribute) {
+ return function (el, name) {
+ return el.hasAttribute(name);
+ };
+ } else {
+ return function (el, name) {
+ return el.getAttribute(name) !== null;
+ };
+ }
+ }()
+ };
+ var oldAddEventListener = domEvents.addEventListener;
+ domEvents.addEventListener = function (eventName, handler) {
+ var special = attr.special[eventName];
+ if (special && special.addEventListener) {
+ var teardown = special.addEventListener.call(this, eventName, handler, oldAddEventListener);
+ var teardowns = setData.get.call(this, 'attrTeardowns');
+ if (!teardowns) {
+ setData.set.call(this, 'attrTeardowns', teardowns = {});
+ }
+ if (!teardowns[eventName]) {
+ teardowns[eventName] = [];
+ }
+ teardowns[eventName].push({
+ teardown: teardown,
+ handler: handler
+ });
+ return;
+ }
+ return oldAddEventListener.apply(this, arguments);
+ };
+ var oldRemoveEventListener = domEvents.removeEventListener;
+ domEvents.removeEventListener = function (eventName, handler) {
+ var special = attr.special[eventName];
+ if (special && special.addEventListener) {
+ var teardowns = setData.get.call(this, 'attrTeardowns');
+ if (teardowns && teardowns[eventName]) {
+ var eventTeardowns = teardowns[eventName];
+ for (var i = 0, len = eventTeardowns.length; i < len; i++) {
+ if (eventTeardowns[i].handler === handler) {
+ eventTeardowns[i].teardown.call(this, oldRemoveEventListener);
+ eventTeardowns.splice(i, 1);
+ break;
+ }
+ }
+ if (eventTeardowns.length === 0) {
+ delete teardowns[eventName];
+ }
+ }
+ return;
+ }
+ return oldRemoveEventListener.apply(this, arguments);
+ };
+ module.exports = exports = attr;
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#dom/child-nodes/child-nodes*/
+define('can-util/dom/child-nodes/child-nodes', function (require, exports, module) {
+ function childNodes(node) {
+ var childNodes = node.childNodes;
+ if ('length' in childNodes) {
+ return childNodes;
+ } else {
+ var cur = node.firstChild;
+ var nodes = [];
+ while (cur) {
+ nodes.push(cur);
+ cur = cur.nextSibling;
+ }
+ return nodes;
+ }
+ }
+ module.exports = childNodes;
+});
+/*can-util@3.3.3#dom/class-name/class-name*/
+define('can-util/dom/class-name/class-name', function (require, exports, module) {
+ var has = function (className) {
+ if (this.classList) {
+ return this.classList.contains(className);
+ } else {
+ return !!this.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
+ }
+ };
+ module.exports = {
+ has: has,
+ add: function (className) {
+ if (this.classList) {
+ this.classList.add(className);
+ } else if (!has.call(this, className)) {
+ this.className += ' ' + className;
+ }
+ },
+ remove: function (className) {
+ if (this.classList) {
+ this.classList.remove(className);
+ } else if (has.call(this, className)) {
+ var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
+ this.className = this.className.replace(reg, ' ');
+ }
+ }
+ };
+});
+/*can-util@3.3.3#dom/fragment/fragment*/
+define('can-util/dom/fragment/fragment', function (require, exports, module) {
+ var getDocument = require('can-util/dom/document/document'), childNodes = require('can-util/dom/child-nodes/child-nodes');
+ var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name, doc) {
+ if (name === undefined) {
+ name = fragmentRE.test(html) && RegExp.$1;
+ }
+ if (html && toString.call(html.replace) === '[object Function]') {
+ html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>$2>');
+ }
+ var container = doc.createElement('div'), temp = doc.createElement('div');
+ if (name === 'tbody' || name === 'tfoot' || name === 'thead' || name === 'colgroup') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild;
+ } else if (name === 'col') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild;
+ } else if (name === 'tr') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild;
+ } else if (name === 'td' || name === 'th') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild;
+ } else if (name === 'option') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild;
+ } else {
+ container.innerHTML = '' + html;
+ }
+ var tmp = {}, children = childNodes(container);
+ tmp.length = children.length;
+ for (var i = 0; i < children.length; i++) {
+ tmp[i] = children[i];
+ }
+ return [].slice.call(tmp);
+ };
+ var buildFragment = function (html, doc) {
+ if (html && html.nodeType === 11) {
+ return html;
+ }
+ if (!doc) {
+ doc = getDocument();
+ } else if (doc.length) {
+ doc = doc[0];
+ }
+ var parts = fragment(html, undefined, doc), frag = (doc || document).createDocumentFragment();
+ for (var i = 0, length = parts.length; i < length; i++) {
+ frag.appendChild(parts[i]);
+ }
+ return frag;
+ };
+ module.exports = buildFragment;
+});
+/*can-util@3.3.3#dom/frag/frag*/
+define('can-util/dom/frag/frag', function (require, exports, module) {
+ var getDocument = require('can-util/dom/document/document');
+ var fragment = require('can-util/dom/fragment/fragment');
+ var each = require('can-util/js/each/each');
+ var childNodes = require('can-util/dom/child-nodes/child-nodes');
+ var makeFrag = function (item, doc) {
+ var document = doc || getDocument();
+ var frag;
+ if (!item || typeof item === 'string') {
+ frag = fragment(item == null ? '' : '' + item, document);
+ if (!frag.childNodes.length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ } else if (item.nodeType === 11) {
+ return item;
+ } else if (typeof item.nodeType === 'number') {
+ frag = document.createDocumentFragment();
+ frag.appendChild(item);
+ return frag;
+ } else if (typeof item.length === 'number') {
+ frag = document.createDocumentFragment();
+ each(item, function (item) {
+ frag.appendChild(makeFrag(item));
+ });
+ if (!childNodes(frag).length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ } else {
+ frag = fragment('' + item, document);
+ if (!childNodes(frag).length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ }
+ };
+ module.exports = makeFrag;
+});
+/*can-util@3.3.3#dom/matches/matches*/
+define('can-util/dom/matches/matches', function (require, exports, module) {
+ var matchesMethod = function (element) {
+ return element.matches || element.webkitMatchesSelector || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || element.oMatchesSelector;
+ };
+ module.exports = function () {
+ var method = matchesMethod(this);
+ return method ? method.apply(this, arguments) : false;
+ };
+});
+/*can-util@3.3.3#dom/mutate/mutate*/
+define('can-util/dom/mutate/mutate', function (require, exports, module) {
+ var makeArray = require('can-util/js/make-array/make-array');
+ var setImmediate = require('can-util/js/set-immediate/set-immediate');
+ var CID = require('can-cid');
+ var getMutationObserver = require('can-util/dom/mutation-observer/mutation-observer');
+ var childNodes = require('can-util/dom/child-nodes/child-nodes');
+ var domContains = require('can-util/dom/contains/contains');
+ var domDispatch = require('can-util/dom/dispatch/dispatch');
+ var DOCUMENT = require('can-util/dom/document/document');
+ var domData = require('can-util/dom/data/data');
+ var mutatedElements;
+ var checks = {
+ inserted: function (root, elem) {
+ return domContains.call(root, elem);
+ },
+ removed: function (root, elem) {
+ return !domContains.call(root, elem);
+ }
+ };
+ var fireOn = function (elems, root, check, event, dispatched) {
+ if (!elems.length) {
+ return;
+ }
+ var children, cid;
+ for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) {
+ cid = CID(elem);
+ if (elem.getElementsByTagName && check(root, elem) && !dispatched[cid]) {
+ dispatched[cid] = true;
+ children = makeArray(elem.getElementsByTagName('*'));
+ domDispatch.call(elem, event, [], false);
+ if (event === 'removed') {
+ domData.delete.call(elem);
+ }
+ for (var j = 0, child; (child = children[j]) !== undefined; j++) {
+ cid = CID(child);
+ if (!dispatched[cid]) {
+ domDispatch.call(child, event, [], false);
+ if (event === 'removed') {
+ domData.delete.call(child);
+ }
+ dispatched[cid] = true;
+ }
+ }
+ }
+ }
+ };
+ var fireMutations = function () {
+ var mutations = mutatedElements;
+ mutatedElements = null;
+ var firstElement = mutations[0][1][0];
+ var doc = DOCUMENT() || firstElement.ownerDocument || firstElement;
+ var root = doc.contains ? doc : doc.body;
+ var dispatched = {
+ inserted: {},
+ removed: {}
+ };
+ mutations.forEach(function (mutation) {
+ fireOn(mutation[1], root, checks[mutation[0]], mutation[0], dispatched[mutation[0]]);
+ });
+ };
+ var mutated = function (elements, type) {
+ if (!getMutationObserver() && elements.length) {
+ var firstElement = elements[0];
+ var doc = DOCUMENT() || firstElement.ownerDocument || firstElement;
+ var root = doc.contains ? doc : doc.body;
+ if (checks.inserted(root, firstElement)) {
+ if (!mutatedElements) {
+ mutatedElements = [];
+ setImmediate(fireMutations);
+ }
+ mutatedElements.push([
+ type,
+ elements
+ ]);
+ }
+ }
+ };
+ module.exports = {
+ appendChild: function (child) {
+ if (getMutationObserver()) {
+ this.appendChild(child);
+ } else {
+ var children;
+ if (child.nodeType === 11) {
+ children = makeArray(childNodes(child));
+ } else {
+ children = [child];
+ }
+ this.appendChild(child);
+ mutated(children, 'inserted');
+ }
+ },
+ insertBefore: function (child, ref, document) {
+ if (getMutationObserver()) {
+ this.insertBefore(child, ref);
+ } else {
+ var children;
+ if (child.nodeType === 11) {
+ children = makeArray(childNodes(child));
+ } else {
+ children = [child];
+ }
+ this.insertBefore(child, ref);
+ mutated(children, 'inserted');
+ }
+ },
+ removeChild: function (child) {
+ if (getMutationObserver()) {
+ this.removeChild(child);
+ } else {
+ mutated([child], 'removed');
+ this.removeChild(child);
+ }
+ },
+ replaceChild: function (newChild, oldChild) {
+ if (getMutationObserver()) {
+ this.replaceChild(newChild, oldChild);
+ } else {
+ var children;
+ if (newChild.nodeType === 11) {
+ children = makeArray(childNodes(newChild));
+ } else {
+ children = [newChild];
+ }
+ mutated([oldChild], 'removed');
+ this.replaceChild(newChild, oldChild);
+ mutated(children, 'inserted');
+ }
+ },
+ inserted: function (elements) {
+ mutated(elements, 'inserted');
+ },
+ removed: function (elements) {
+ mutated(elements, 'removed');
+ }
+ };
+});
+/*can-util@3.3.3#dom/dom*/
+define('can-util/dom/dom', function (require, exports, module) {
+ (function (global) {
+ module.exports = {
+ ajax: require('can-util/dom/ajax/ajax'),
+ attr: require('can-util/dom/attr/attr'),
+ childNodes: require('can-util/dom/child-nodes/child-nodes'),
+ className: require('can-util/dom/class-name/class-name'),
+ contains: require('can-util/dom/contains/contains'),
+ data: require('can-util/dom/data/data'),
+ dispatch: require('can-util/dom/dispatch/dispatch'),
+ document: require('can-util/dom/document/document'),
+ events: require('can-util/dom/events/events'),
+ frag: require('can-util/dom/frag/frag'),
+ fragment: require('can-util/dom/fragment/fragment'),
+ isOfGlobalDocument: require('can-util/dom/is-of-global-document/is-of-global-document'),
+ matches: require('can-util/dom/matches/matches'),
+ mutate: require('can-util/dom/mutate/mutate'),
+ mutationObserver: require('can-util/dom/mutation-observer/mutation-observer')
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/cid/cid*/
+define('can-util/js/cid/cid', function (require, exports, module) {
+ module.exports = require('can-cid');
+});
+/*can-util@3.3.3#js/import/import*/
+define('can-util/js/import/import', function (require, exports, module) {
+ (function (global) {
+ var isFunction = require('can-util/js/is-function/is-function');
+ var global = require('can-util/js/global/global')();
+ module.exports = function (moduleName, parentName) {
+ return new Promise(function (resolve, reject) {
+ try {
+ if (typeof global.System === 'object' && isFunction(global.System['import'])) {
+ global.System['import'](moduleName, { name: parentName }).then(resolve, reject);
+ } else if (global.define && global.define.amd) {
+ global.require([moduleName], function (value) {
+ resolve(value);
+ });
+ } else if (global.require) {
+ resolve(global.require(moduleName));
+ } else {
+ resolve();
+ }
+ } catch (err) {
+ reject(err);
+ }
+ });
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/is-browser-window/is-browser-window*/
+define('can-util/js/is-browser-window/is-browser-window', function (require, exports, module) {
+ (function (global) {
+ module.exports = function () {
+ return typeof window !== 'undefined' && typeof document !== 'undefined' && typeof SimpleDOM === 'undefined';
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/is-node/is-node*/
+define('can-util/js/is-node/is-node', function (require, exports, module) {
+ (function (global) {
+ module.exports = function () {
+ return typeof process === 'object' && {}.toString.call(process) === '[object process]';
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/is-promise/is-promise*/
+define('can-util/js/is-promise/is-promise', function (require, exports, module) {
+ var types = require('can-types');
+ module.exports = function (obj) {
+ return types.isPromise(obj);
+ };
+});
+/*can-util@3.3.3#js/is-string/is-string*/
+define('can-util/js/is-string/is-string', function (require, exports, module) {
+ module.exports = function isString(obj) {
+ return typeof obj === 'string';
+ };
+});
+/*can-util@3.3.3#js/is-web-worker/is-web-worker*/
+define('can-util/js/is-web-worker/is-web-worker', function (require, exports, module) {
+ (function (global) {
+ module.exports = function () {
+ return typeof WorkerGlobalScope !== 'undefined' && this instanceof WorkerGlobalScope;
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#js/join-uris/join-uris*/
+define('can-util/js/join-uris/join-uris', function (require, exports, module) {
+ var parseURI = require('can-util/js/parse-uri/parse-uri');
+ module.exports = function (base, href) {
+ function removeDotSegments(input) {
+ var output = [];
+ input.replace(/^(\.\.?(\/|$))+/, '').replace(/\/(\.(\/|$))+/g, '/').replace(/\/\.\.$/, '/../').replace(/\/?[^\/]*/g, function (p) {
+ if (p === '/..') {
+ output.pop();
+ } else {
+ output.push(p);
+ }
+ });
+ return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
+ }
+ href = parseURI(href || '');
+ base = parseURI(base || '');
+ return !href || !base ? null : (href.protocol || base.protocol) + (href.protocol || href.authority ? href.authority : base.authority) + removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : href.pathname ? (base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname : base.pathname) + (href.protocol || href.authority || href.pathname ? href.search : href.search || base.search) + href.hash;
+ };
+});
+/*can-util@3.3.3#js/last/last*/
+define('can-util/js/last/last', function (require, exports, module) {
+ module.exports = function (arr) {
+ return arr && arr[arr.length - 1];
+ };
+});
+/*can-util@3.3.3#js/types/types*/
+define('can-util/js/types/types', function (require, exports, module) {
+ module.exports = require('can-types');
+});
+/*can-util@3.3.3#js/js*/
+define('can-util/js/js', function (require, exports, module) {
+ (function (global) {
+ module.exports = {
+ assign: require('can-util/js/assign/assign'),
+ cid: require('can-util/js/cid/cid'),
+ deepAssign: require('can-util/js/deep-assign/deep-assign'),
+ dev: require('can-util/js/dev/dev'),
+ diff: require('can-util/js/diff/diff'),
+ each: require('can-util/js/each/each'),
+ global: require('can-util/js/global/global'),
+ 'import': require('can-util/js/import/import'),
+ isArray: require('can-util/js/is-array/is-array'),
+ isArrayLike: require('can-util/js/is-array-like/is-array-like'),
+ isBrowserWindow: require('can-util/js/is-browser-window/is-browser-window'),
+ isEmptyObject: require('can-util/js/is-empty-object/is-empty-object'),
+ isFunction: require('can-util/js/is-function/is-function'),
+ isNode: require('can-util/js/is-node/is-node'),
+ isPlainObject: require('can-util/js/is-plain-object/is-plain-object'),
+ isPromise: require('can-util/js/is-promise/is-promise'),
+ isString: require('can-util/js/is-string/is-string'),
+ isWebWorker: require('can-util/js/is-web-worker/is-web-worker'),
+ joinURIs: require('can-util/js/join-uris/join-uris'),
+ last: require('can-util/js/last/last'),
+ makeArray: require('can-util/js/make-array/make-array'),
+ omit: require('can-util/js/omit/omit'),
+ setImmediate: require('can-util/js/set-immediate/set-immediate'),
+ string: require('can-util/js/string/string'),
+ types: require('can-util/js/types/types')
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.3.3#can-util*/
+define('can-util', function (require, exports, module) {
+ var deepAssign = require('can-util/js/deep-assign/deep-assign');
+ var omit = require('can-util/js/omit/omit');
+ var namespace = require('can-namespace');
+ module.exports = deepAssign(namespace, require('can-util/dom/dom'), omit(require('can-util/js/js'), [
+ 'cid',
+ 'types'
+ ]));
+});
+/*[global-shim-end]*/
+(function(){ // jshint ignore:line
+ window._define = window.define;
+ window.define = window.define.orig;
+}
+)();
\ No newline at end of file