From 975a43ab3a895f56accc44293bdf669977af64d4 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Fri, 1 Dec 2017 14:15:21 -0800 Subject: [PATCH] 3.1.6 --- dist/amd/can-view-target.js | 219 ++ dist/global/can-view-target.js | 3835 ++++++++++++++++++++++++++++++++ 2 files changed, 4054 insertions(+) create mode 100644 dist/amd/can-view-target.js create mode 100644 dist/global/can-view-target.js diff --git a/dist/amd/can-view-target.js b/dist/amd/can-view-target.js new file mode 100644 index 0000000..8accb23 --- /dev/null +++ b/dist/amd/can-view-target.js @@ -0,0 +1,219 @@ +/*can-view-target@3.1.5#can-view-target*/ +define([ + 'require', + 'exports', + 'module', + 'can-util/dom/child-nodes', + 'can-util/dom/attr', + 'can-util/js/each', + 'can-util/js/make-array', + 'can-globals/document', + 'can-util/dom/mutate', + 'can-namespace', + 'can-globals/mutation-observer' +], function (require, exports, module) { + (function (global, require, exports, module) { + var childNodes = require('can-util/dom/child-nodes'); + var domAttr = require('can-util/dom/attr'); + var each = require('can-util/js/each'); + var makeArray = require('can-util/js/make-array'); + var getDocument = require('can-globals/document'); + var domMutate = require('can-util/dom/mutate'); + var namespace = require('can-namespace'); + var MUTATION_OBSERVER = require('can-globals/mutation-observer'); + var processNodes = function (nodes, paths, location, document) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + frag.appendChild(processNode(node, paths, location.concat(i), document)); + } + return frag; + }, keepsTextNodes = typeof document !== 'undefined' && function () { + var testFrag = document.createDocumentFragment(); + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + testFrag.appendChild(div); + var cloned = testFrag.cloneNode(true); + return childNodes(cloned.firstChild).length === 2; + }(), clonesWork = typeof document !== 'undefined' && function () { + var el = document.createElement('a'); + el.innerHTML = ''; + var clone = el.cloneNode(true); + var works = clone.innerHTML === ''; + var MO, observer; + if (works) { + el = document.createDocumentFragment(); + el.appendChild(document.createTextNode('foo-bar')); + MO = MUTATION_OBSERVER(); + if (MO) { + observer = new MO(function () { + }); + observer.observe(document.documentElement, { + childList: true, + subtree: true + }); + clone = el.cloneNode(true); + observer.disconnect(); + } else { + clone = el.cloneNode(true); + } + return clone.childNodes.length === 1; + } + return works; + }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS; + var cloneNode = clonesWork ? function (el) { + return el.cloneNode(true); + } : function (node) { + var document = node.ownerDocument; + var copy; + if (node.nodeType === 1) { + if (node.namespaceURI !== 'http://www.w3.org/1999/xhtml' && namespacesWork && document.createElementNS) { + copy = document.createElementNS(node.namespaceURI, node.nodeName); + } else { + copy = document.createElement(node.nodeName); + } + } else if (node.nodeType === 3) { + copy = document.createTextNode(node.nodeValue); + } else if (node.nodeType === 8) { + copy = document.createComment(node.nodeValue); + } else if (node.nodeType === 11) { + copy = document.createDocumentFragment(); + } + if (node.attributes) { + var attributes = makeArray(node.attributes); + each(attributes, function (node) { + if (node && node.specified) { + domAttr.setAttribute(copy, node.nodeName || node.name, node.nodeValue || node.value); + } + }); + } + if (node && node.firstChild) { + var child = node.firstChild; + while (child) { + copy.appendChild(cloneNode(child)); + child = child.nextSibling; + } + } + return copy; + }; + function processNode(node, paths, location, document) { + var callback, loc = location, nodeType = typeof node, el, p, i, len; + var getCallback = function () { + if (!callback) { + callback = { + path: location, + callbacks: [] + }; + paths.push(callback); + loc = []; + } + return callback; + }; + if (nodeType === 'object') { + if (node.tag) { + if (namespacesWork && node.namespace) { + el = document.createElementNS(node.namespace, node.tag); + } else { + el = document.createElement(node.tag); + } + if (node.attrs) { + for (var attrName in node.attrs) { + var value = node.attrs[attrName]; + if (typeof value === 'function') { + getCallback().callbacks.push({ callback: value }); + } else { + domAttr.setAttribute(el, attrName, value); + } + } + } + if (node.attributes) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.attributes[i] }); + } + } + if (node.children && node.children.length) { + if (callback) { + p = callback.paths = []; + } else { + p = paths; + } + el.appendChild(processNodes(node.children, p, loc, document)); + } + } else if (node.comment) { + el = document.createComment(node.comment); + if (node.callbacks) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.callbacks[i] }); + } + } + } + } else if (nodeType === 'string') { + el = document.createTextNode(node); + } else if (nodeType === 'function') { + if (keepsTextNodes) { + el = document.createTextNode(''); + getCallback().callbacks.push({ callback: node }); + } else { + el = document.createComment('~'); + getCallback().callbacks.push({ + callback: function () { + var el = document.createTextNode(''); + domMutate.replaceChild.call(this.parentNode, el, this); + return node.apply(el, arguments); + } + }); + } + } + return el; + } + function getCallbacks(el, pathData, elementCallbacks) { + var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, child = el, pathLength = path ? path.length : 0, pathsLength = paths ? paths.length : 0; + for (var i = 0; i < pathLength; i++) { + child = child.childNodes.item(path[i]); + } + for (i = 0; i < pathsLength; i++) { + getCallbacks(child, paths[i], elementCallbacks); + } + elementCallbacks.push({ + element: child, + callbacks: callbacks + }); + } + function hydrateCallbacks(callbacks, args) { + var len = callbacks.length, callbacksLength, callbackElement, callbackData; + for (var i = 0; i < len; i++) { + callbackData = callbacks[i]; + callbacksLength = callbackData.callbacks.length; + callbackElement = callbackData.element; + for (var c = 0; c < callbacksLength; c++) { + callbackData.callbacks[c].callback.apply(callbackElement, args); + } + } + } + function makeTarget(nodes, doc) { + var paths = []; + var frag = processNodes(nodes, paths, [], doc || getDocument()); + return { + paths: paths, + clone: frag, + hydrate: function () { + var cloned = cloneNode(this.clone); + var args = makeArray(arguments); + var callbacks = []; + for (var i = 0; i < paths.length; i++) { + getCallbacks(cloned, paths[i], callbacks); + } + hydrateCallbacks(callbacks, args); + return cloned; + } + }; + } + makeTarget.keepsTextNodes = keepsTextNodes; + makeTarget.cloneNode = cloneNode; + namespace.view = namespace.view || {}; + module.exports = namespace.view.target = makeTarget; + }(function () { + return this; + }(), require, exports, module)); +}); \ No newline at end of file diff --git a/dist/global/can-view-target.js b/dist/global/can-view-target.js new file mode 100644 index 0000000..711f72e --- /dev/null +++ b/dist/global/can-view-target.js @@ -0,0 +1,3835 @@ +/*[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 hasCjsDependencies = function(deps) { + return ( + deps[0] === "require" && deps[1] === "exports" && deps[2] === "module" + ); + }; + + 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 (hasCjsDependencies(deps) || (!deps.length && callback.length)) { + module = { exports: {} }; + args[0] = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args[1] = module.exports; + args[2] = module; + } else if (!args[0] && deps[0] === "exports") { + // Babel uses the exports and module object. + 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" }, + typeof self == "object" && self.Object == Object ? self : window, + function(__$source__, __$global__) { + // jshint ignore:line + eval("(function() { " + __$source__ + " \n }).call(__$global__);"); + } +); + +/*can-util@3.10.18#dom/child-nodes/child-nodes*/ +define('can-util/dom/child-nodes/child-nodes', function (require, exports, module) { + 'use strict'; + 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-namespace@1.0.0#can-namespace*/ +define('can-namespace', function (require, exports, module) { + module.exports = {}; +}); +/*can-symbol@1.4.2#can-symbol*/ +define('can-symbol', [ + 'require', + 'exports', + 'module', + 'can-namespace' +], function (require, exports, module) { + (function (global, require, exports, module) { + var namespace = require('can-namespace'); + var CanSymbol; + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + CanSymbol = Symbol; + } else { + var symbolNum = 0; + CanSymbol = function CanSymbolPolyfill(description) { + var symbolValue = '@@symbol' + symbolNum++ + description; + var symbol = {}; + Object.defineProperties(symbol, { + toString: { + value: function () { + return symbolValue; + } + } + }); + return symbol; + }; + var descriptionToSymbol = {}; + var symbolToDescription = {}; + CanSymbol.for = function (description) { + var symbol = descriptionToSymbol[description]; + if (!symbol) { + symbol = descriptionToSymbol[description] = CanSymbol(description); + symbolToDescription[symbol] = description; + } + return symbol; + }; + CanSymbol.keyFor = function (symbol) { + return symbolToDescription[symbol]; + }; + [ + 'hasInstance', + 'isConcatSpreadable', + 'iterator', + 'match', + 'prototype', + 'replace', + 'search', + 'species', + 'split', + 'toPrimitive', + 'toStringTag', + 'unscopables' + ].forEach(function (name) { + CanSymbol[name] = CanSymbol.for(name); + }); + } + [ + 'isMapLike', + 'isListLike', + 'isValueLike', + 'isFunctionLike', + 'getOwnKeys', + 'getOwnKeyDescriptor', + 'proto', + 'getOwnEnumerableKeys', + 'hasOwnKey', + 'size', + 'getName', + 'getIdentity', + 'assignDeep', + 'updateDeep', + 'getValue', + 'setValue', + 'getKeyValue', + 'setKeyValue', + 'updateValues', + 'addValue', + 'removeValues', + 'apply', + 'new', + 'onValue', + 'offValue', + 'onKeyValue', + 'offKeyValue', + 'getKeyDependencies', + 'getValueDependencies', + 'keyHasDependencies', + 'valueHasDependencies', + 'onKeys', + 'onKeysAdded', + 'onKeysRemoved' + ].forEach(function (name) { + CanSymbol.for('can.' + name); + }); + module.exports = namespace.Symbol = CanSymbol; + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-reflect@1.10.2#reflections/helpers*/ +define('can-reflect/reflections/helpers', [ + 'require', + 'exports', + 'module', + 'can-symbol' +], function (require, exports, module) { + var canSymbol = require('can-symbol'); + module.exports = { + makeGetFirstSymbolValue: function (symbolNames) { + var symbols = symbolNames.map(function (name) { + return canSymbol.for(name); + }); + var length = symbols.length; + return function getFirstSymbol(obj) { + var index = -1; + while (++index < length) { + if (obj[symbols[index]] !== undefined) { + return obj[symbols[index]]; + } + } + }; + }, + hasLength: function (list) { + var type = typeof list; + var length = list && type !== 'boolean' && typeof list !== 'number' && 'length' in list && list.length; + return typeof list !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in list); + } + }; +}); +/*can-reflect@1.10.2#reflections/type/type*/ +define('can-reflect/reflections/type/type', [ + 'require', + 'exports', + 'module', + 'can-symbol', + 'can-reflect/reflections/helpers' +], function (require, exports, module) { + var canSymbol = require('can-symbol'); + var helpers = require('can-reflect/reflections/helpers'); + var plainFunctionPrototypePropertyNames = Object.getOwnPropertyNames(function () { + }.prototype); + var plainFunctionPrototypeProto = Object.getPrototypeOf(function () { + }.prototype); + function isConstructorLike(func) { + var value = func[canSymbol.for('can.new')]; + if (value !== undefined) { + return value; + } + if (typeof func !== 'function') { + return false; + } + var prototype = func.prototype; + if (!prototype) { + return false; + } + if (plainFunctionPrototypeProto !== Object.getPrototypeOf(prototype)) { + return true; + } + var propertyNames = Object.getOwnPropertyNames(prototype); + if (propertyNames.length === plainFunctionPrototypePropertyNames.length) { + for (var i = 0, len = propertyNames.length; i < len; i++) { + if (propertyNames[i] !== plainFunctionPrototypePropertyNames[i]) { + return true; + } + } + return false; + } else { + return true; + } + } + var getNewOrApply = helpers.makeGetFirstSymbolValue([ + 'can.new', + 'can.apply' + ]); + function isFunctionLike(obj) { + var result, symbolValue = obj[canSymbol.for('can.isFunctionLike')]; + if (symbolValue !== undefined) { + return symbolValue; + } + result = getNewOrApply(obj); + if (result !== undefined) { + return !!result; + } + return typeof obj === 'function'; + } + function isPrimitive(obj) { + var type = typeof obj; + if (obj == null || type !== 'function' && type !== 'object') { + return true; + } else { + return false; + } + } + function isBuiltIn(obj) { + if (isPrimitive(obj) || Array.isArray(obj) || isPlainObject(obj) || Object.prototype.toString.call(obj) !== '[object Object]' && Object.prototype.toString.call(obj).indexOf('[object ') !== -1) { + return true; + } else { + return false; + } + } + function isValueLike(obj) { + var symbolValue; + if (isPrimitive(obj)) { + return true; + } + symbolValue = obj[canSymbol.for('can.isValueLike')]; + if (typeof symbolValue !== 'undefined') { + return symbolValue; + } + var value = obj[canSymbol.for('can.getValue')]; + if (value !== undefined) { + return !!value; + } + } + function isMapLike(obj) { + if (isPrimitive(obj)) { + return false; + } + var isMapLike = obj[canSymbol.for('can.isMapLike')]; + if (typeof isMapLike !== 'undefined') { + return !!isMapLike; + } + var value = obj[canSymbol.for('can.getKeyValue')]; + if (value !== undefined) { + return !!value; + } + return true; + } + var onValueSymbol = canSymbol.for('can.onValue'), onKeyValueSymbol = canSymbol.for('can.onKeyValue'), onPatchesSymbol = canSymbol.for('can.onPatches'); + function isObservableLike(obj) { + if (isPrimitive(obj)) { + return false; + } + return Boolean(obj[onValueSymbol] || obj[onKeyValueSymbol] || obj[onPatchesSymbol]); + } + function isListLike(list) { + var symbolValue, type = typeof list; + if (type === 'string') { + return true; + } + if (isPrimitive(list)) { + return false; + } + symbolValue = list[canSymbol.for('can.isListLike')]; + if (typeof symbolValue !== 'undefined') { + return symbolValue; + } + var value = list[canSymbol.iterator]; + if (value !== undefined) { + return !!value; + } + if (Array.isArray(list)) { + return true; + } + return helpers.hasLength(list); + } + var supportsSymbols = typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'; + var isSymbolLike; + if (supportsSymbols) { + isSymbolLike = function (symbol) { + return typeof symbol === 'symbol'; + }; + } else { + var symbolStart = '@@symbol'; + isSymbolLike = function (symbol) { + if (typeof symbol === 'object' && !Array.isArray(symbol)) { + return symbol.toString().substr(0, symbolStart.length) === symbolStart; + } else { + return false; + } + }; + } + var coreHasOwn = Object.prototype.hasOwnProperty; + var funcToString = Function.prototype.toString; + var objectCtorString = funcToString.call(Object); + function isPlainObject(obj) { + if (!obj || typeof obj !== 'object') { + return false; + } + var proto = Object.getPrototypeOf(obj); + if (proto === Object.prototype || proto === null) { + return true; + } + var Constructor = coreHasOwn.call(proto, 'constructor') && proto.constructor; + return typeof Constructor === 'function' && Constructor instanceof Constructor && funcToString.call(Constructor) === objectCtorString; + } + module.exports = { + isConstructorLike: isConstructorLike, + isFunctionLike: isFunctionLike, + isListLike: isListLike, + isMapLike: isMapLike, + isObservableLike: isObservableLike, + isPrimitive: isPrimitive, + isBuiltIn: isBuiltIn, + isValueLike: isValueLike, + isSymbolLike: isSymbolLike, + isMoreListLikeThanMapLike: function (obj) { + if (Array.isArray(obj)) { + return true; + } + if (obj instanceof Array) { + return true; + } + var value = obj[canSymbol.for('can.isMoreListLikeThanMapLike')]; + if (value !== undefined) { + return value; + } + var isListLike = this.isListLike(obj), isMapLike = this.isMapLike(obj); + if (isListLike && !isMapLike) { + return true; + } else if (!isListLike && isMapLike) { + return false; + } + }, + isIteratorLike: function (obj) { + return obj && typeof obj === 'object' && typeof obj.next === 'function' && obj.next.length === 0; + }, + isPromise: function (obj) { + return obj instanceof Promise || Object.prototype.toString.call(obj) === '[object Promise]'; + }, + isPlainObject: isPlainObject + }; +}); +/*can-reflect@1.10.2#reflections/call/call*/ +define('can-reflect/reflections/call/call', [ + 'require', + 'exports', + 'module', + 'can-symbol', + 'can-reflect/reflections/type/type' +], function (require, exports, module) { + var canSymbol = require('can-symbol'); + var typeReflections = require('can-reflect/reflections/type/type'); + module.exports = { + call: function (func, context) { + var args = [].slice.call(arguments, 2); + var apply = func[canSymbol.for('can.apply')]; + if (apply) { + return apply.call(func, context, args); + } else { + return func.apply(context, args); + } + }, + apply: function (func, context, args) { + var apply = func[canSymbol.for('can.apply')]; + if (apply) { + return apply.call(func, context, args); + } else { + return func.apply(context, args); + } + }, + 'new': function (func) { + var args = [].slice.call(arguments, 1); + var makeNew = func[canSymbol.for('can.new')]; + if (makeNew) { + return makeNew.apply(func, args); + } else { + var context = Object.create(func.prototype); + var ret = func.apply(context, args); + if (typeReflections.isPrimitive(ret)) { + return context; + } else { + return ret; + } + } + } + }; +}); +/*can-reflect@1.10.2#reflections/get-set/get-set*/ +define('can-reflect/reflections/get-set/get-set', [ + 'require', + 'exports', + 'module', + 'can-symbol', + 'can-reflect/reflections/type/type' +], function (require, exports, module) { + var canSymbol = require('can-symbol'); + var typeReflections = require('can-reflect/reflections/type/type'); + var setKeyValueSymbol = canSymbol.for('can.setKeyValue'), getKeyValueSymbol = canSymbol.for('can.getKeyValue'), getValueSymbol = canSymbol.for('can.getValue'), setValueSymbol = canSymbol.for('can.setValue'); + var reflections = { + setKeyValue: function (obj, key, value) { + if (typeReflections.isSymbolLike(key)) { + if (typeof key === 'symbol') { + obj[key] = value; + } else { + Object.defineProperty(obj, key, { + enumerable: false, + configurable: true, + value: value, + writable: true + }); + } + return; + } + var setKeyValue = obj[setKeyValueSymbol]; + if (setKeyValue !== undefined) { + return setKeyValue.call(obj, key, value); + } else { + obj[key] = value; + } + }, + getKeyValue: function (obj, key) { + var getKeyValue = obj[getKeyValueSymbol]; + if (getKeyValue) { + return getKeyValue.call(obj, key); + } + return obj[key]; + }, + deleteKeyValue: function (obj, key) { + var deleteKeyValue = obj[canSymbol.for('can.deleteKeyValue')]; + if (deleteKeyValue) { + return deleteKeyValue.call(obj, key); + } + delete obj[key]; + }, + getValue: function (value) { + if (typeReflections.isPrimitive(value)) { + return value; + } + var getValue = value[getValueSymbol]; + if (getValue) { + return getValue.call(value); + } + return value; + }, + setValue: function (item, value) { + var setValue = item && item[setValueSymbol]; + if (setValue) { + return setValue.call(item, value); + } else { + throw new Error('can-reflect.setValue - Can not set value.'); + } + }, + splice: function (obj, index, removing, adding) { + var howMany; + if (typeof removing !== 'number') { + var updateValues = obj[canSymbol.for('can.updateValues')]; + if (updateValues) { + return updateValues.call(obj, index, removing, adding); + } + howMany = removing.length; + } else { + howMany = removing; + } + var splice = obj[canSymbol.for('can.splice')]; + if (splice) { + return splice.call(obj, index, howMany, adding); + } + return [].splice.apply(obj, [ + index, + howMany + ].concat(adding)); + }, + addValues: function (obj, adding, index) { + var add = obj[canSymbol.for('can.addValues')]; + if (add) { + return add.call(obj, adding, index); + } + if (Array.isArray(obj) && index === undefined) { + return obj.push.apply(obj, adding); + } + return reflections.splice(obj, index, [], adding); + }, + removeValues: function (obj, removing, index) { + var removeValues = obj[canSymbol.for('can.removeValues')]; + if (removeValues) { + return removeValues.call(obj, removing, index); + } + if (Array.isArray(obj) && index === undefined) { + removing.forEach(function (item) { + var index = obj.indexOf(item); + if (index >= 0) { + obj.splice(index, 1); + } + }); + return; + } + return reflections.splice(obj, index, removing, []); + } + }; + reflections.get = reflections.getKeyValue; + reflections.set = reflections.setKeyValue; + reflections['delete'] = reflections.deleteKeyValue; + module.exports = reflections; +}); +/*can-reflect@1.10.2#reflections/observe/observe*/ +define('can-reflect/reflections/observe/observe', [ + 'require', + 'exports', + 'module', + 'can-symbol' +], function (require, exports, module) { + var canSymbol = require('can-symbol'); + var slice = [].slice; + function makeFallback(symbolName, fallbackName) { + return function (obj, event, handler, queueName) { + var method = obj[canSymbol.for(symbolName)]; + if (method !== undefined) { + return method.call(obj, event, handler, queueName); + } + return this[fallbackName].apply(this, arguments); + }; + } + function makeErrorIfMissing(symbolName, errorMessage) { + return function (obj) { + var method = obj[canSymbol.for(symbolName)]; + if (method !== undefined) { + var args = slice.call(arguments, 1); + return method.apply(obj, args); + } + throw new Error(errorMessage); + }; + } + module.exports = { + onKeyValue: makeFallback('can.onKeyValue', 'onEvent'), + offKeyValue: makeFallback('can.offKeyValue', 'offEvent'), + onKeys: makeErrorIfMissing('can.onKeys', 'can-reflect: can not observe an onKeys event'), + onKeysAdded: makeErrorIfMissing('can.onKeysAdded', 'can-reflect: can not observe an onKeysAdded event'), + onKeysRemoved: makeErrorIfMissing('can.onKeysRemoved', 'can-reflect: can not unobserve an onKeysRemoved event'), + getKeyDependencies: makeErrorIfMissing('can.getKeyDependencies', 'can-reflect: can not determine dependencies'), + getWhatIChange: makeErrorIfMissing('can.getWhatIChange', 'can-reflect: can not determine dependencies'), + getChangesDependencyRecord: function getChangesDependencyRecord(handler) { + var fn = handler[canSymbol.for('can.getChangesDependencyRecord')]; + if (typeof fn === 'function') { + return fn(); + } + }, + keyHasDependencies: makeErrorIfMissing('can.keyHasDependencies', 'can-reflect: can not determine if this has key dependencies'), + onValue: makeErrorIfMissing('can.onValue', 'can-reflect: can not observe value change'), + offValue: makeErrorIfMissing('can.offValue', 'can-reflect: can not unobserve value change'), + getValueDependencies: makeErrorIfMissing('can.getValueDependencies', 'can-reflect: can not determine dependencies'), + valueHasDependencies: makeErrorIfMissing('can.valueHasDependencies', 'can-reflect: can not determine if value has dependencies'), + onPatches: makeErrorIfMissing('can.onPatches', 'can-reflect: can not observe patches on object'), + offPatches: makeErrorIfMissing('can.offPatches', 'can-reflect: can not unobserve patches on object'), + onInstanceBoundChange: makeErrorIfMissing('can.onInstanceBoundChange', 'can-reflect: can not observe bound state change in instances.'), + offInstanceBoundChange: makeErrorIfMissing('can.offInstanceBoundChange', 'can-reflect: can not unobserve bound state change'), + isBound: makeErrorIfMissing('can.isBound', 'can-reflect: cannot determine if object is bound'), + onEvent: function (obj, eventName, callback, queue) { + if (obj) { + var onEvent = obj[canSymbol.for('can.onEvent')]; + if (onEvent !== undefined) { + return onEvent.call(obj, eventName, callback, queue); + } else if (obj.addEventListener) { + obj.addEventListener(eventName, callback, queue); + } + } + }, + offEvent: function (obj, eventName, callback, queue) { + if (obj) { + var offEvent = obj[canSymbol.for('can.offEvent')]; + if (offEvent !== undefined) { + return offEvent.call(obj, eventName, callback, queue); + } else if (obj.removeEventListener) { + obj.removeEventListener(eventName, callback, queue); + } + } + }, + setPriority: function (obj, priority) { + if (obj) { + var setPriority = obj[canSymbol.for('can.setPriority')]; + if (setPriority !== undefined) { + setPriority.call(obj, priority); + return true; + } + } + return false; + }, + getPriority: function (obj) { + if (obj) { + var getPriority = obj[canSymbol.for('can.getPriority')]; + if (getPriority !== undefined) { + return getPriority.call(obj); + } + } + return undefined; + } + }; +}); +/*can-reflect@1.10.2#reflections/shape/shape*/ +define('can-reflect/reflections/shape/shape', [ + 'require', + 'exports', + 'module', + 'can-symbol', + 'can-reflect/reflections/get-set/get-set', + 'can-reflect/reflections/type/type', + 'can-reflect/reflections/helpers' +], function (require, exports, module) { + var canSymbol = require('can-symbol'); + var getSetReflections = require('can-reflect/reflections/get-set/get-set'); + var typeReflections = require('can-reflect/reflections/type/type'); + var helpers = require('can-reflect/reflections/helpers'); + var shapeReflections; + var shiftFirstArgumentToThis = function (func) { + return function () { + var args = [this]; + args.push.apply(args, arguments); + return func.apply(null, args); + }; + }; + var getKeyValueSymbol = canSymbol.for('can.getKeyValue'); + var shiftedGetKeyValue = shiftFirstArgumentToThis(getSetReflections.getKeyValue); + var setKeyValueSymbol = canSymbol.for('can.setKeyValue'); + var shiftedSetKeyValue = shiftFirstArgumentToThis(getSetReflections.setKeyValue); + var sizeSymbol = canSymbol.for('can.size'); + var serializeMap = null; + var hasUpdateSymbol = helpers.makeGetFirstSymbolValue([ + 'can.updateDeep', + 'can.assignDeep', + 'can.setKeyValue' + ]); + var shouldUpdateOrAssign = function (obj) { + return typeReflections.isPlainObject(obj) || Array.isArray(obj) || !!hasUpdateSymbol(obj); + }; + function isSerializable(obj) { + if (typeReflections.isPrimitive(obj)) { + return true; + } + if (hasUpdateSymbol(obj)) { + return false; + } + return typeReflections.isBuiltIn(obj) && !typeReflections.isPlainObject(obj); + } + var Object_Keys; + try { + Object.keys(1); + Object_Keys = Object.keys; + } catch (e) { + Object_Keys = function (obj) { + if (typeReflections.isPrimitive(obj)) { + return []; + } else { + return Object.keys(obj); + } + }; + } + function makeSerializer(methodName, symbolsToCheck) { + return function serializer(value, MapType) { + if (isSerializable(value)) { + return value; + } + var firstSerialize; + if (MapType && !serializeMap) { + serializeMap = { + unwrap: new MapType(), + serialize: new MapType() + }; + firstSerialize = true; + } + var serialized; + if (typeReflections.isValueLike(value)) { + serialized = this[methodName](getSetReflections.getValue(value)); + } else { + var isListLike = typeReflections.isIteratorLike(value) || typeReflections.isMoreListLikeThanMapLike(value); + serialized = isListLike ? [] : {}; + if (serializeMap) { + if (serializeMap[methodName].has(value)) { + return serializeMap[methodName].get(value); + } else { + serializeMap[methodName].set(value, serialized); + } + } + for (var i = 0, len = symbolsToCheck.length; i < len; i++) { + var serializer = value[symbolsToCheck[i]]; + if (serializer) { + var result = serializer.call(value, serialized); + if (firstSerialize) { + serializeMap = null; + } + return result; + } + } + if (typeof obj === 'function') { + if (serializeMap) { + serializeMap[methodName].set(value, value); + } + serialized = value; + } else if (isListLike) { + this.eachIndex(value, function (childValue, index) { + serialized[index] = this[methodName](childValue); + }, this); + } else { + this.eachKey(value, function (childValue, prop) { + serialized[prop] = this[methodName](childValue); + }, this); + } + } + if (firstSerialize) { + serializeMap = null; + } + return serialized; + }; + } + var makeMap; + if (typeof Map !== 'undefined') { + makeMap = function (keys) { + var map = new Map(); + shapeReflections.eachIndex(keys, function (key) { + map.set(key, true); + }); + return map; + }; + } else { + makeMap = function (keys) { + var map = {}; + keys.forEach(function (key) { + map[key] = true; + }); + return { + get: function (key) { + return map[key]; + }, + set: function (key, value) { + map[key] = value; + }, + keys: function () { + return keys; + } + }; + }; + } + var fastHasOwnKey = function (obj) { + var hasOwnKey = obj[canSymbol.for('can.hasOwnKey')]; + if (hasOwnKey) { + return hasOwnKey.bind(obj); + } else { + var map = makeMap(shapeReflections.getOwnEnumerableKeys(obj)); + return function (key) { + return map.get(key); + }; + } + }; + function addPatch(patches, patch) { + var lastPatch = patches[patches.length - 1]; + if (lastPatch) { + if (lastPatch.deleteCount === lastPatch.insert.length && patch.index - lastPatch.index === lastPatch.deleteCount) { + lastPatch.insert.push.apply(lastPatch.insert, patch.insert); + lastPatch.deleteCount += patch.deleteCount; + return; + } + } + patches.push(patch); + } + function updateDeepList(target, source, isAssign) { + var sourceArray = this.toArray(source); + var patches = [], lastIndex = -1; + this.eachIndex(target, function (curVal, index) { + lastIndex = index; + if (index >= sourceArray.length) { + if (!isAssign) { + addPatch(patches, { + index: index, + deleteCount: sourceArray.length - index + 1, + insert: [] + }); + } + return false; + } + var newVal = sourceArray[index]; + if (typeReflections.isPrimitive(curVal) || typeReflections.isPrimitive(newVal) || shouldUpdateOrAssign(curVal) === false) { + addPatch(patches, { + index: index, + deleteCount: 1, + insert: [newVal] + }); + } else { + this.updateDeep(curVal, newVal); + } + }, this); + if (sourceArray.length > lastIndex) { + addPatch(patches, { + index: lastIndex + 1, + deleteCount: 0, + insert: sourceArray.slice(lastIndex + 1) + }); + } + for (var i = 0, patchLen = patches.length; i < patchLen; i++) { + var patch = patches[i]; + getSetReflections.splice(target, patch.index, patch.deleteCount, patch.insert); + } + return target; + } + shapeReflections = { + each: function (obj, callback, context) { + if (typeReflections.isIteratorLike(obj) || typeReflections.isMoreListLikeThanMapLike(obj)) { + return this.eachIndex(obj, callback, context); + } else { + return this.eachKey(obj, callback, context); + } + }, + eachIndex: function (list, callback, context) { + if (Array.isArray(list)) { + return this.eachListLike(list, callback, context); + } else { + var iter, iterator = list[canSymbol.iterator]; + if (typeReflections.isIteratorLike(list)) { + iter = list; + } else if (iterator) { + iter = iterator.call(list); + } + if (iter) { + var res, index = 0; + while (!(res = iter.next()).done) { + if (callback.call(context || list, res.value, index++, list) === false) { + break; + } + } + } else { + this.eachListLike(list, callback, context); + } + } + return list; + }, + eachListLike: function (list, callback, context) { + var index = -1; + var length = list.length; + if (length === undefined) { + var size = list[sizeSymbol]; + if (size) { + length = size.call(list); + } else { + throw new Error('can-reflect: unable to iterate.'); + } + } + while (++index < length) { + var item = list[index]; + if (callback.call(context || item, item, index, list) === false) { + break; + } + } + return list; + }, + toArray: function (obj) { + var arr = []; + this.each(obj, function (value) { + arr.push(value); + }); + return arr; + }, + eachKey: function (obj, callback, context) { + if (obj) { + var enumerableKeys = this.getOwnEnumerableKeys(obj); + var getKeyValue = obj[getKeyValueSymbol] || shiftedGetKeyValue; + return this.eachIndex(enumerableKeys, function (key) { + var value = getKeyValue.call(obj, key); + return callback.call(context || obj, value, key, obj); + }); + } + return obj; + }, + 'hasOwnKey': function (obj, key) { + var hasOwnKey = obj[canSymbol.for('can.hasOwnKey')]; + if (hasOwnKey) { + return hasOwnKey.call(obj, key); + } + var getOwnKeys = obj[canSymbol.for('can.getOwnKeys')]; + if (getOwnKeys) { + var found = false; + this.eachIndex(getOwnKeys.call(obj), function (objKey) { + if (objKey === key) { + found = true; + return false; + } + }); + return found; + } + return obj.hasOwnProperty(key); + }, + getOwnEnumerableKeys: function (obj) { + var getOwnEnumerableKeys = obj[canSymbol.for('can.getOwnEnumerableKeys')]; + if (getOwnEnumerableKeys) { + return getOwnEnumerableKeys.call(obj); + } + if (obj[canSymbol.for('can.getOwnKeys')] && obj[canSymbol.for('can.getOwnKeyDescriptor')]) { + var keys = []; + this.eachIndex(this.getOwnKeys(obj), function (key) { + var descriptor = this.getOwnKeyDescriptor(obj, key); + if (descriptor.enumerable) { + keys.push(key); + } + }, this); + return keys; + } else { + return Object_Keys(obj); + } + }, + getOwnKeys: function (obj) { + var getOwnKeys = obj[canSymbol.for('can.getOwnKeys')]; + if (getOwnKeys) { + return getOwnKeys.call(obj); + } else { + return Object.getOwnPropertyNames(obj); + } + }, + getOwnKeyDescriptor: function (obj, key) { + var getOwnKeyDescriptor = obj[canSymbol.for('can.getOwnKeyDescriptor')]; + if (getOwnKeyDescriptor) { + return getOwnKeyDescriptor.call(obj, key); + } else { + return Object.getOwnPropertyDescriptor(obj, key); + } + }, + unwrap: makeSerializer('unwrap', [canSymbol.for('can.unwrap')]), + serialize: makeSerializer('serialize', [ + canSymbol.for('can.serialize'), + canSymbol.for('can.unwrap') + ]), + assignMap: function (target, source) { + var hasOwnKey = fastHasOwnKey(target); + var getKeyValue = target[getKeyValueSymbol] || shiftedGetKeyValue; + var setKeyValue = target[setKeyValueSymbol] || shiftedSetKeyValue; + this.eachKey(source, function (value, key) { + if (!hasOwnKey(key) || getKeyValue.call(target, key) !== value) { + setKeyValue.call(target, key, value); + } + }); + return target; + }, + assignList: function (target, source) { + var inserting = this.toArray(source); + getSetReflections.splice(target, 0, inserting, inserting); + return target; + }, + assign: function (target, source) { + if (typeReflections.isIteratorLike(source) || typeReflections.isMoreListLikeThanMapLike(source)) { + this.assignList(target, source); + } else { + this.assignMap(target, source); + } + return target; + }, + assignDeepMap: function (target, source) { + var hasOwnKey = fastHasOwnKey(target); + var getKeyValue = target[getKeyValueSymbol] || shiftedGetKeyValue; + var setKeyValue = target[setKeyValueSymbol] || shiftedSetKeyValue; + this.eachKey(source, function (newVal, key) { + if (!hasOwnKey(key)) { + getSetReflections.setKeyValue(target, key, newVal); + } else { + var curVal = getKeyValue.call(target, key); + if (newVal === curVal) { + } else if (typeReflections.isPrimitive(curVal) || typeReflections.isPrimitive(newVal) || shouldUpdateOrAssign(curVal) === false) { + setKeyValue.call(target, key, newVal); + } else { + this.assignDeep(curVal, newVal); + } + } + }, this); + return target; + }, + assignDeepList: function (target, source) { + return updateDeepList.call(this, target, source, true); + }, + assignDeep: function (target, source) { + var assignDeep = target[canSymbol.for('can.assignDeep')]; + if (assignDeep) { + assignDeep.call(target, source); + } else if (typeReflections.isMoreListLikeThanMapLike(source)) { + this.assignDeepList(target, source); + } else { + this.assignDeepMap(target, source); + } + return target; + }, + updateMap: function (target, source) { + var sourceKeyMap = makeMap(this.getOwnEnumerableKeys(source)); + var sourceGetKeyValue = source[getKeyValueSymbol] || shiftedGetKeyValue; + var targetSetKeyValue = target[setKeyValueSymbol] || shiftedSetKeyValue; + this.eachKey(target, function (curVal, key) { + if (!sourceKeyMap.get(key)) { + getSetReflections.deleteKeyValue(target, key); + return; + } + sourceKeyMap.set(key, false); + var newVal = sourceGetKeyValue.call(source, key); + if (newVal !== curVal) { + targetSetKeyValue.call(target, key, newVal); + } + }, this); + this.eachIndex(sourceKeyMap.keys(), function (key) { + if (sourceKeyMap.get(key)) { + targetSetKeyValue.call(target, key, sourceGetKeyValue.call(source, key)); + } + }); + return target; + }, + updateList: function (target, source) { + var inserting = this.toArray(source); + getSetReflections.splice(target, 0, target, inserting); + return target; + }, + update: function (target, source) { + if (typeReflections.isIteratorLike(source) || typeReflections.isMoreListLikeThanMapLike(source)) { + this.updateList(target, source); + } else { + this.updateMap(target, source); + } + return target; + }, + updateDeepMap: function (target, source) { + var sourceKeyMap = makeMap(this.getOwnEnumerableKeys(source)); + var sourceGetKeyValue = source[getKeyValueSymbol] || shiftedGetKeyValue; + var targetSetKeyValue = target[setKeyValueSymbol] || shiftedSetKeyValue; + this.eachKey(target, function (curVal, key) { + if (!sourceKeyMap.get(key)) { + getSetReflections.deleteKeyValue(target, key); + return; + } + sourceKeyMap.set(key, false); + var newVal = sourceGetKeyValue.call(source, key); + if (typeReflections.isPrimitive(curVal) || typeReflections.isPrimitive(newVal) || shouldUpdateOrAssign(curVal) === false) { + targetSetKeyValue.call(target, key, newVal); + } else { + this.updateDeep(curVal, newVal); + } + }, this); + this.eachIndex(sourceKeyMap.keys(), function (key) { + if (sourceKeyMap.get(key)) { + targetSetKeyValue.call(target, key, sourceGetKeyValue.call(source, key)); + } + }); + return target; + }, + updateDeepList: function (target, source) { + return updateDeepList.call(this, target, source); + }, + updateDeep: function (target, source) { + var updateDeep = target[canSymbol.for('can.updateDeep')]; + if (updateDeep) { + updateDeep.call(target, source); + } else if (typeReflections.isMoreListLikeThanMapLike(source)) { + this.updateDeepList(target, source); + } else { + this.updateDeepMap(target, source); + } + return target; + }, + 'in': function () { + }, + getAllEnumerableKeys: function () { + }, + getAllKeys: function () { + }, + assignSymbols: function (target, source) { + this.eachKey(source, function (value, key) { + var symbol = typeReflections.isSymbolLike(canSymbol[key]) ? canSymbol[key] : canSymbol.for(key); + getSetReflections.setKeyValue(target, symbol, value); + }); + return target; + }, + isSerializable: isSerializable, + size: function (obj) { + var size = obj[sizeSymbol]; + var count = 0; + if (size) { + return size.call(obj); + } else if (helpers.hasLength(obj)) { + return obj.length; + } else if (typeReflections.isListLike(obj)) { + this.each(obj, function () { + count++; + }); + return count; + } else if (obj) { + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + count++; + } + } + return count; + } else { + return undefined; + } + }, + defineInstanceKey: function (cls, key, properties) { + var defineInstanceKey = cls[canSymbol.for('can.defineInstanceKey')]; + if (defineInstanceKey) { + return defineInstanceKey.call(cls, key, properties); + } + var proto = cls.prototype; + defineInstanceKey = proto[canSymbol.for('can.defineInstanceKey')]; + if (defineInstanceKey) { + defineInstanceKey.call(proto, key, properties); + } else { + Object.defineProperty(proto, key, shapeReflections.assign({ + configurable: true, + enumerable: !typeReflections.isSymbolLike(key), + writable: true + }, properties)); + } + } + }; + shapeReflections.keys = shapeReflections.getOwnEnumerableKeys; + module.exports = shapeReflections; +}); +/*can-reflect@1.10.2#reflections/get-name/get-name*/ +define('can-reflect/reflections/get-name/get-name', [ + 'require', + 'exports', + 'module', + 'can-symbol', + 'can-reflect/reflections/type/type' +], function (require, exports, module) { + var canSymbol = require('can-symbol'); + var typeReflections = require('can-reflect/reflections/type/type'); + var getNameSymbol = canSymbol.for('can.getName'); + function setName(obj, nameGetter) { + if (typeof nameGetter !== 'function') { + var value = nameGetter; + nameGetter = function () { + return value; + }; + } + Object.defineProperty(obj, getNameSymbol, { value: nameGetter }); + } + function getName(obj) { + var nameGetter = obj[getNameSymbol]; + if (nameGetter) { + return nameGetter.call(obj); + } + if (typeof obj === 'function') { + return obj.name; + } + if (obj.constructor && obj !== obj.constructor) { + var parent = getName(obj.constructor); + if (parent) { + if (typeReflections.isValueLike(obj)) { + return parent + '<>'; + } + if (typeReflections.isMoreListLikeThanMapLike(obj)) { + return parent + '[]'; + } + if (typeReflections.isMapLike(obj)) { + return parent + '{}'; + } + } + } + return undefined; + } + module.exports = { + setName: setName, + getName: getName + }; +}); +/*can-reflect@1.10.2#types/map*/ +define('can-reflect/types/map', [ + 'require', + 'exports', + 'module', + 'can-reflect/reflections/shape/shape', + 'can-symbol' +], function (require, exports, module) { + var shape = require('can-reflect/reflections/shape/shape'); + var CanSymbol = require('can-symbol'); + function keysPolyfill() { + var keys = []; + var currentIndex = 0; + this.forEach(function (val, key) { + keys.push(key); + }); + return { + next: function () { + return { + value: keys[currentIndex], + done: currentIndex++ === keys.length + }; + } + }; + } + if (typeof Map !== 'undefined') { + shape.assignSymbols(Map.prototype, { + 'can.getOwnEnumerableKeys': Map.prototype.keys, + 'can.setKeyValue': Map.prototype.set, + 'can.getKeyValue': Map.prototype.get, + 'can.deleteKeyValue': Map.prototype['delete'], + 'can.hasOwnKey': Map.prototype.has + }); + if (typeof Map.prototype.keys !== 'function') { + Map.prototype.keys = Map.prototype[CanSymbol.for('can.getOwnEnumerableKeys')] = keysPolyfill; + } + } + if (typeof WeakMap !== 'undefined') { + shape.assignSymbols(WeakMap.prototype, { + 'can.getOwnEnumerableKeys': function () { + throw new Error('can-reflect: WeakMaps do not have enumerable keys.'); + }, + 'can.setKeyValue': WeakMap.prototype.set, + 'can.getKeyValue': WeakMap.prototype.get, + 'can.deleteKeyValue': WeakMap.prototype['delete'], + 'can.hasOwnKey': WeakMap.prototype.has + }); + } +}); +/*can-reflect@1.10.2#types/set*/ +define('can-reflect/types/set', [ + 'require', + 'exports', + 'module', + 'can-reflect/reflections/shape/shape', + 'can-symbol' +], function (require, exports, module) { + var shape = require('can-reflect/reflections/shape/shape'); + var CanSymbol = require('can-symbol'); + if (typeof Set !== 'undefined') { + shape.assignSymbols(Set.prototype, { + 'can.isMoreListLikeThanMapLike': true, + 'can.updateValues': function (index, removing, adding) { + if (removing !== adding) { + shape.each(removing, function (value) { + this.delete(value); + }, this); + } + shape.each(adding, function (value) { + this.add(value); + }, this); + }, + 'can.size': function () { + return this.size; + } + }); + if (typeof Set.prototype[CanSymbol.iterator] !== 'function') { + Set.prototype[CanSymbol.iterator] = function () { + var arr = []; + var currentIndex = 0; + this.forEach(function (val) { + arr.push(val); + }); + return { + next: function () { + return { + value: arr[currentIndex], + done: currentIndex++ === arr.length + }; + } + }; + }; + } + } + if (typeof WeakSet !== 'undefined') { + shape.assignSymbols(WeakSet.prototype, { + 'can.isListLike': true, + 'can.isMoreListLikeThanMapLike': true, + 'can.updateValues': function (index, removing, adding) { + if (removing !== adding) { + shape.each(removing, function (value) { + this.delete(value); + }, this); + } + shape.each(adding, function (value) { + this.add(value); + }, this); + }, + 'can.size': function () { + throw new Error('can-reflect: WeakSets do not have enumerable keys.'); + } + }); + } +}); +/*can-reflect@1.10.2#can-reflect*/ +define('can-reflect', [ + 'require', + 'exports', + 'module', + 'can-reflect/reflections/call/call', + 'can-reflect/reflections/get-set/get-set', + 'can-reflect/reflections/observe/observe', + 'can-reflect/reflections/shape/shape', + 'can-reflect/reflections/type/type', + 'can-reflect/reflections/get-name/get-name', + 'can-namespace', + 'can-reflect/types/map', + 'can-reflect/types/set' +], function (require, exports, module) { + var functionReflections = require('can-reflect/reflections/call/call'); + var getSet = require('can-reflect/reflections/get-set/get-set'); + var observe = require('can-reflect/reflections/observe/observe'); + var shape = require('can-reflect/reflections/shape/shape'); + var type = require('can-reflect/reflections/type/type'); + var getName = require('can-reflect/reflections/get-name/get-name'); + var namespace = require('can-namespace'); + var reflect = {}; + [ + functionReflections, + getSet, + observe, + shape, + type, + getName + ].forEach(function (reflections) { + for (var prop in reflections) { + reflect[prop] = reflections[prop]; + } + }); + require('can-reflect/types/map'); + require('can-reflect/types/set'); + module.exports = namespace.Reflect = reflect; +}); +/*can-globals@0.3.0#can-globals-proto*/ +define('can-globals/can-globals-proto', [ + 'require', + 'exports', + 'module', + 'can-reflect' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var canReflect = require('can-reflect'); + function dispatch(key) { + var handlers = this.eventHandlers[key]; + if (handlers) { + var handlersCopy = handlers.slice(); + var value = this.getKeyValue(key); + for (var i = 0; i < handlersCopy.length; i++) { + handlersCopy[i](value); + } + } + } + function Globals() { + this.eventHandlers = {}; + this.properties = {}; + } + Globals.prototype.define = function (key, value, enableCache) { + if (enableCache === undefined) { + enableCache = true; + } + if (!this.properties[key]) { + this.properties[key] = { + default: value, + value: value, + enableCache: enableCache + }; + } + return this; + }; + Globals.prototype.getKeyValue = function (key) { + var property = this.properties[key]; + if (property) { + if (typeof property.value === 'function') { + if (property.cachedValue) { + return property.cachedValue; + } + if (property.enableCache) { + property.cachedValue = property.value(); + return property.cachedValue; + } else { + return property.value(); + } + } + return property.value; + } + }; + Globals.prototype.makeExport = function (key) { + return function (value) { + if (arguments.length === 0) { + return this.getKeyValue(key); + } + if (typeof value === 'undefined' || value === null) { + this.deleteKeyValue(key); + } else { + if (typeof value === 'function') { + this.setKeyValue(key, function () { + return value; + }); + } else { + this.setKeyValue(key, value); + } + return value; + } + }.bind(this); + }; + Globals.prototype.offKeyValue = function (key, handler) { + if (this.properties[key]) { + var handlers = this.eventHandlers[key]; + if (handlers) { + var i = handlers.indexOf(handler); + handlers.splice(i, 1); + } + } + return this; + }; + Globals.prototype.onKeyValue = function (key, handler) { + if (this.properties[key]) { + if (!this.eventHandlers[key]) { + this.eventHandlers[key] = []; + } + this.eventHandlers[key].push(handler); + } + return this; + }; + Globals.prototype.deleteKeyValue = function (key) { + var property = this.properties[key]; + if (property !== undefined) { + property.value = property.default; + property.cachedValue = undefined; + dispatch.call(this, key); + } + return this; + }; + Globals.prototype.setKeyValue = function (key, value) { + if (!this.properties[key]) { + return this.define(key, value); + } + var property = this.properties[key]; + property.value = value; + property.cachedValue = undefined; + dispatch.call(this, key); + return this; + }; + Globals.prototype.reset = function () { + for (var key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + this.properties[key].value = this.properties[key].default; + this.properties[key].cachedValue = undefined; + dispatch.call(this, key); + } + } + return this; + }; + canReflect.assignSymbols(Globals.prototype, { + 'can.getKeyValue': Globals.prototype.getKeyValue, + 'can.setKeyValue': Globals.prototype.setKeyValue, + 'can.deleteKeyValue': Globals.prototype.deleteKeyValue, + 'can.onKeyValue': Globals.prototype.onKeyValue, + 'can.offKeyValue': Globals.prototype.offKeyValue + }); + module.exports = Globals; + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-globals@0.3.0#can-globals-instance*/ +define('can-globals/can-globals-instance', [ + 'require', + 'exports', + 'module', + 'can-namespace', + 'can-globals/can-globals-proto' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var namespace = require('can-namespace'); + var Globals = require('can-globals/can-globals-proto'); + var globals = new Globals(); + if (namespace.globals) { + throw new Error('You can\'t have two versions of can-globals, check your dependencies'); + } else { + module.exports = namespace.globals = globals; + } + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-globals@0.3.0#global/global*/ +define('can-globals/global/global', [ + 'require', + 'exports', + 'module', + 'can-globals/can-globals-instance' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var globals = require('can-globals/can-globals-instance'); + globals.define('global', function () { + return typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : typeof process === 'object' && {}.toString.call(process) === '[object process]' ? global : window; + }); + module.exports = globals.makeExport('global'); + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-util@3.10.18#js/set-immediate/set-immediate*/ +define('can-util/js/set-immediate/set-immediate', [ + 'require', + 'exports', + 'module', + 'can-globals/global/global' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var global = require('can-globals/global/global')(); + module.exports = global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }; + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-globals@0.3.0#document/document*/ +define('can-globals/document/document', [ + 'require', + 'exports', + 'module', + 'can-globals/global/global', + 'can-globals/can-globals-instance' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + require('can-globals/global/global'); + var globals = require('can-globals/can-globals-instance'); + globals.define('document', function () { + return globals.getKeyValue('global').document; + }); + module.exports = globals.makeExport('document'); + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-util@3.10.18#dom/is-of-global-document/is-of-global-document*/ +define('can-util/dom/is-of-global-document/is-of-global-document', [ + 'require', + 'exports', + 'module', + 'can-globals/document/document' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var getDocument = require('can-globals/document/document'); + module.exports = function (el) { + return (el.ownerDocument || el) === getDocument(); + }; + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-cid@1.1.2#can-cid*/ +define('can-cid', [ + 'require', + 'exports', + 'module', + 'can-namespace' +], function (require, exports, module) { + var namespace = require('can-namespace'); + var _cid = 0; + var domExpando = 'can' + new Date(); + var cid = function (object, name) { + var propertyName = object.nodeName ? domExpando : '_cid'; + if (!object[propertyName]) { + _cid++; + object[propertyName] = (name || '') + _cid; + } + return object[propertyName]; + }; + cid.domExpando = domExpando; + cid.get = function (object) { + var type = typeof object; + var isObject = type !== null && (type === 'object' || type === 'function'); + return isObject ? cid(object) : type + ':' + object; + }; + 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-dom-data-state@0.2.0#can-dom-data-state*/ +define('can-dom-data-state', [ + 'require', + 'exports', + 'module', + 'can-namespace', + 'can-cid' +], function (require, exports, module) { + 'use strict'; + var namespace = require('can-namespace'); + var CID = require('can-cid'); + var data = {}; + var isEmptyObject = function (obj) { + for (var prop in obj) { + return false; + } + return true; + }; + var setData = function (name, value) { + var id = CID(this); + var store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + }; + var deleteNode = function () { + var id = CID.get(this); + var nodeDeleted = false; + if (id && data[id]) { + nodeDeleted = true; + delete data[id]; + } + return nodeDeleted; + }; + var domDataState = { + _data: data, + getCid: function () { + return CID.get(this); + }, + cid: function () { + return CID(this); + }, + expando: CID.domExpando, + get: function (key) { + var id = CID.get(this), store = id && data[id]; + return key === undefined ? store : store && store[key]; + }, + set: setData, + clean: function (prop) { + var id = CID.get(this); + var itemData = data[id]; + if (itemData && itemData[prop]) { + delete itemData[prop]; + } + if (isEmptyObject(itemData)) { + deleteNode.call(this); + } + }, + delete: deleteNode + }; + if (namespace.domDataState) { + throw new Error('You can\'t have two versions of can-dom-data-state, check your dependencies'); + } else { + module.exports = namespace.domDataState = domDataState; + } +}); +/*can-globals@0.3.0#mutation-observer/mutation-observer*/ +define('can-globals/mutation-observer/mutation-observer', [ + 'require', + 'exports', + 'module', + 'can-globals/global/global', + 'can-globals/can-globals-instance' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + require('can-globals/global/global'); + var globals = require('can-globals/can-globals-instance'); + globals.define('MutationObserver', function () { + var GLOBAL = globals.getKeyValue('global'); + return GLOBAL.MutationObserver || GLOBAL.WebKitMutationObserver || GLOBAL.MozMutationObserver; + }); + module.exports = globals.makeExport('MutationObserver'); + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-util@3.10.18#js/is-array-like/is-array-like*/ +define('can-util/js/is-array-like/is-array-like', function (require, exports, module) { + 'use strict'; + 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-util@3.10.18#js/is-iterable/is-iterable*/ +define('can-util/js/is-iterable/is-iterable', [ + 'require', + 'exports', + 'module', + 'can-symbol' +], function (require, exports, module) { + 'use strict'; + var canSymbol = require('can-symbol'); + module.exports = function (obj) { + return obj && !!obj[canSymbol.iterator || canSymbol.for('iterator')]; + }; +}); +/*can-util@3.10.18#js/each/each*/ +define('can-util/js/each/each', [ + 'require', + 'exports', + 'module', + 'can-util/js/is-array-like/is-array-like', + 'can-util/js/is-iterable/is-iterable', + 'can-symbol' +], function (require, exports, module) { + 'use strict'; + 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 canSymbol = require('can-symbol'); + 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[canSymbol.iterator || canSymbol.for('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.1.2#helpers*/ +define('can-cid/helpers', function (require, exports, module) { + module.exports = { + each: function (obj, cb, context) { + for (var prop in obj) { + cb.call(context, obj[prop], prop); + } + return obj; + } + }; +}); +/*can-cid@1.1.2#set/set*/ +define('can-cid/set/set', [ + 'require', + 'exports', + 'module', + 'can-cid', + 'can-cid/helpers' +], function (require, exports, module) { + 'use strict'; + var getCID = require('can-cid').get; + var helpers = require('can-cid/helpers'); + var CIDSet; + if (typeof Set !== 'undefined') { + CIDSet = 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) { + helpers.each(this.values, cb, thisArg); + }; + CIDSet.prototype.has = function (value) { + return getCID(value) in this.values; + }; + CIDSet.prototype.clear = function () { + return this.values = {}; + }; + Object.defineProperty(CIDSet.prototype, 'size', { + get: function () { + var size = 0; + helpers.each(this.values, function () { + size++; + }); + return size; + } + }); + } + module.exports = CIDSet; +}); +/*can-util@3.10.18#js/make-array/make-array*/ +define('can-util/js/make-array/make-array', [ + 'require', + 'exports', + 'module', + 'can-util/js/each/each', + 'can-util/js/is-array-like/is-array-like' +], function (require, exports, module) { + 'use strict'; + 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.10.18#js/is-container/is-container*/ +define('can-util/js/is-container/is-container', function (require, exports, module) { + 'use strict'; + module.exports = function (current) { + return /^f|^o/.test(typeof current); + }; +}); +/*can-util@3.10.18#js/get/get*/ +define('can-util/js/get/get', [ + 'require', + 'exports', + 'module', + 'can-util/js/is-container/is-container' +], function (require, exports, module) { + 'use strict'; + 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-log@0.1.2#can-log*/ +define('can-log', function (require, exports, module) { + 'use strict'; + 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-log@0.1.2#dev/dev*/ +define('can-log/dev/dev', [ + 'require', + 'exports', + 'module', + 'can-log' +], function (require, exports, module) { + 'use strict'; + var canLog = require('can-log'); + module.exports = { + warnTimeout: 5000, + logLevel: 0, + stringify: function (value) { + var flagUndefined = function flagUndefined(key, value) { + return value === undefined ? '/* void(undefined) */' : value; + }; + return JSON.stringify(value, flagUndefined, ' ').replace(/"\/\* void\(undefined\) \*\/"/g, 'undefined'); + }, + warn: function () { + }, + log: function () { + }, + error: function () { + }, + _logger: canLog._logger + }; +}); +/*can-util@3.10.18#js/is-array/is-array*/ +define('can-util/js/is-array/is-array', [ + 'require', + 'exports', + 'module', + 'can-log/dev/dev' +], function (require, exports, module) { + 'use strict'; + var dev = require('can-log/dev/dev'); + var hasWarned = false; + module.exports = function (arr) { + return Array.isArray(arr); + }; +}); +/*can-util@3.10.18#js/string/string*/ +define('can-util/js/string/string', [ + 'require', + 'exports', + 'module', + 'can-util/js/get/get', + 'can-util/js/is-container/is-container', + 'can-log/dev/dev', + 'can-util/js/is-array/is-array' +], function (require, exports, module) { + 'use strict'; + var get = require('can-util/js/get/get'); + var isContainer = require('can-util/js/is-container/is-container'); + var canDev = require('can-log/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.10.18#dom/mutation-observer/document/document*/ +define('can-util/dom/mutation-observer/document/document', [ + 'require', + 'exports', + 'module', + 'can-globals/document/document', + 'can-dom-data-state', + 'can-globals/mutation-observer/mutation-observer', + 'can-util/js/each/each', + 'can-cid/set/set', + 'can-util/js/make-array/make-array', + 'can-util/js/string/string' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var getDocument = require('can-globals/document/document'); + var domDataState = require('can-dom-data-state'); + var getMutationObserver = require('can-globals/mutation-observer/mutation-observer'); + var each = require('can-util/js/each/each'); + var CIDStore = require('can-cid/set/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 = getMutationObserver(); + if (MO) { + var documentElement = getDocument().documentElement; + var globalObserverData = domDataState.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: [] + }; + domDataState.set.call(documentElement, 'globalObserverData', globalObserverData); + } + globalObserverData.handlers.push(handler); + } + }, + remove: function (handler) { + var documentElement = getDocument().documentElement; + var globalObserverData = domDataState.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(); + domDataState.clean.call(documentElement, 'globalObserverData'); + } + } + } + }; + var makeMutationMethods = function (name) { + var mutationName = name.toLowerCase() + 'Nodes'; + var getMutationData = function () { + var documentElement = getDocument().documentElement; + var mutationData = domDataState.get.call(documentElement, mutationName + 'MutationData'); + if (!mutationData) { + mutationData = { + name: mutationName, + handlers: [], + afterHandlers: [], + hander: null + }; + if (getMutationObserver()) { + domDataState.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); + domDataState.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; + }(), require, exports, module)); +}); +/*can-util@3.10.18#dom/data/data*/ +define('can-util/dom/data/data', [ + 'require', + 'exports', + 'module', + 'can-dom-data-state', + 'can-util/dom/mutation-observer/document/document' +], function (require, exports, module) { + 'use strict'; + var domDataState = require('can-dom-data-state'); + var mutationDocument = require('can-util/dom/mutation-observer/document/document'); + var elementSetCount = 0; + var deleteNode = function () { + elementSetCount -= 1; + return domDataState.delete.call(this); + }; + var cleanupDomData = function (node) { + if (domDataState.get.call(node) !== undefined) { + deleteNode.call(node); + } + if (elementSetCount === 0) { + mutationDocument.offAfterRemovedNodes(cleanupDomData); + } + }; + module.exports = { + getCid: domDataState.getCid, + cid: domDataState.cid, + expando: domDataState.expando, + clean: domDataState.clean, + get: domDataState.get, + set: function (name, value) { + if (elementSetCount === 0) { + mutationDocument.onAfterRemovedNodes(cleanupDomData); + } + elementSetCount += domDataState.get.call(this) ? 0 : 1; + domDataState.set.call(this, name, value); + }, + delete: deleteNode, + _getElementSetCount: function () { + return elementSetCount; + } + }; +}); +/*can-util@3.10.18#dom/contains/contains*/ +define('can-util/dom/contains/contains', function (require, exports, module) { + 'use strict'; + module.exports = function (child) { + return this.contains(child); + }; +}); +/*can-globals@0.3.0#is-node/is-node*/ +define('can-globals/is-node/is-node', [ + 'require', + 'exports', + 'module', + 'can-globals/can-globals-instance' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var globals = require('can-globals/can-globals-instance'); + globals.define('isNode', function () { + return typeof process === 'object' && {}.toString.call(process) === '[object process]'; + }); + module.exports = globals.makeExport('isNode'); + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-globals@0.3.0#is-browser-window/is-browser-window*/ +define('can-globals/is-browser-window/is-browser-window', [ + 'require', + 'exports', + 'module', + 'can-globals/can-globals-instance', + 'can-globals/is-node/is-node' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var globals = require('can-globals/can-globals-instance'); + require('can-globals/is-node/is-node'); + globals.define('isBrowserWindow', function () { + var isNode = globals.getKeyValue('isNode'); + return typeof window !== 'undefined' && typeof document !== 'undefined' && isNode === false; + }); + module.exports = globals.makeExport('isBrowserWindow'); + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-util@3.10.18#js/is-plain-object/is-plain-object*/ +define('can-util/js/is-plain-object/is-plain-object', function (require, exports, module) { + 'use strict'; + 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) || obj.constructor && obj.constructor.shortName) { + 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.10.18#dom/events/events*/ +define('can-util/dom/events/events', [ + 'require', + 'exports', + 'module', + 'can-globals/document/document', + 'can-globals/is-browser-window/is-browser-window', + 'can-util/js/is-plain-object/is-plain-object', + 'can-log/dev/dev' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var getDocument = require('can-globals/document/document'); + var isBrowserWindow = require('can-globals/is-browser-window/is-browser-window'); + var isPlainObject = require('can-util/js/is-plain-object/is-plain-object'); + var fixSyntheticEventsOnDisabled = false; + var dev = require('can-log/dev/dev'); + 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 ret; + var dispatchingOnDisabled = fixSyntheticEventsOnDisabled && isDispatchingOnDisabled(this, event); + var doc = this.ownerDocument || getDocument(); + var ev = doc.createEvent('HTMLEvents'); + var isString = typeof event === 'string'; + ev.initEvent(isString ? event : event.type, bubbles === undefined ? true : bubbles, false); + if (!isString) { + for (var prop in event) { + if (ev[prop] === undefined) { + ev[prop] = event[prop]; + } + } + } + if (this.disabled === true && ev.type !== 'fix_synthetic_events_on_disabled_test') { + } + ev.args = args; + if (dispatchingOnDisabled) { + this.disabled = false; + } + ret = this.dispatchEvent(ev); + if (dispatchingOnDisabled) { + this.disabled = true; + } + return ret; + } + }; + (function () { + if (!isBrowserWindow()) { + return; + } + var testEventName = 'fix_synthetic_events_on_disabled_test'; + var input = document.createElement('input'); + input.disabled = true; + var timer = setTimeout(function () { + fixSyntheticEventsOnDisabled = true; + }, 50); + var onTest = function onTest() { + clearTimeout(timer); + module.exports.removeEventListener.call(input, testEventName, onTest); + }; + module.exports.addEventListener.call(input, testEventName, onTest); + try { + module.exports.dispatch.call(input, testEventName, [], false); + } catch (e) { + onTest(); + fixSyntheticEventsOnDisabled = true; + } + }()); + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-util@3.10.18#dom/dispatch/dispatch*/ +define('can-util/dom/dispatch/dispatch', [ + 'require', + 'exports', + 'module', + 'can-util/dom/events/events' +], function (require, exports, module) { + 'use strict'; + var domEvents = require('can-util/dom/events/events'); + module.exports = function () { + return domEvents.dispatch.apply(this, arguments); + }; +}); +/*can-types@1.1.5#can-types*/ +define('can-types', [ + 'require', + 'exports', + 'module', + 'can-namespace', + 'can-reflect', + 'can-symbol', + 'can-log/dev/dev' +], function (require, exports, module) { + var namespace = require('can-namespace'); + var canReflect = require('can-reflect'); + var canSymbol = require('can-symbol'); + var dev = require('can-log/dev/dev'); + var types = { + isMapLike: function (obj) { + return canReflect.isObservableLike(obj) && canReflect.isMapLike(obj); + }, + isListLike: function (obj) { + return canReflect.isObservableLike(obj) && canReflect.isListLike(obj); + }, + isPromise: function (obj) { + return canReflect.isPromise(obj); + }, + isConstructor: function (func) { + return canReflect.isConstructorLike(func); + }, + isCallableForValue: function (obj) { + return obj && canReflect.isFunctionLike(obj) && !canReflect.isConstructorLike(obj); + }, + isCompute: function (obj) { + return obj && obj.isComputed; + }, + get iterator() { + return canSymbol.iterator || canSymbol.for('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.10.18#js/diff/diff*/ +define('can-util/js/diff/diff', function (require, exports, module) { + 'use strict'; + var slice = [].slice; + var defaultIdentity = function (a, b) { + return a === b; + }; + function reverseDiff(oldDiffStopIndex, newDiffStopIndex, oldList, newList, identity) { + var oldIndex = oldList.length - 1, newIndex = newList.length - 1; + while (oldIndex > oldDiffStopIndex && newIndex > newDiffStopIndex) { + var oldItem = oldList[oldIndex], newItem = newList[newIndex]; + if (identity(oldItem, newItem)) { + oldIndex--; + newIndex--; + continue; + } else { + return [{ + index: newDiffStopIndex, + deleteCount: oldIndex - oldDiffStopIndex + 1, + insert: slice.call(newList, newDiffStopIndex, newIndex + 1) + }]; + } + } + return [{ + index: newDiffStopIndex, + deleteCount: oldIndex - oldDiffStopIndex + 1, + insert: slice.call(newList, newDiffStopIndex, newIndex + 1) + }]; + } + 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.apply(patches, reverseDiff(oldIndex, newIndex, oldList, newList, identity)); + return patches; + } + } + if (newIndex === newLength && oldIndex === oldLength) { + return patches; + } + patches.push({ + index: newIndex, + deleteCount: oldLength - oldIndex, + insert: slice.call(newList, newIndex) + }); + return patches; + }; +}); +/*can-assign@1.1.1#can-assign*/ +define('can-assign', function (require, exports, module) { + module.exports = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; +}); +/*can-util@3.10.18#dom/events/attributes/attributes*/ +define('can-util/dom/events/attributes/attributes', [ + 'require', + 'exports', + 'module', + 'can-util/dom/events/events', + 'can-util/dom/is-of-global-document/is-of-global-document', + 'can-util/dom/data/data', + 'can-globals/mutation-observer/mutation-observer', + 'can-assign', + 'can-util/dom/dispatch/dispatch' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + 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-globals/mutation-observer/mutation-observer'); + var assign = require('can-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 existingObserver = domData.get.call(this, 'canAttributesObserver'); + if (!existingObserver) { + 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; + }(), require, exports, module)); +}); +/*can-cid@1.1.2#map/map*/ +define('can-cid/map/map', [ + 'require', + 'exports', + 'module', + 'can-cid', + 'can-cid/helpers' +], function (require, exports, module) { + 'use strict'; + var getCID = require('can-cid').get; + var helpers = require('can-cid/helpers'); + var CIDMap; + if (typeof Map !== 'undefined') { + CIDMap = Map; + } else { + var CIDMap = function () { + this.values = {}; + }; + CIDMap.prototype.set = function (key, value) { + this.values[getCID(key)] = { + key: key, + value: value + }; + }; + CIDMap.prototype['delete'] = function (key) { + var has = getCID(key) in this.values; + if (has) { + delete this.values[getCID(key)]; + } + return has; + }; + CIDMap.prototype.forEach = function (cb, thisArg) { + helpers.each(this.values, function (pair) { + return cb.call(thisArg || this, pair.value, pair.key, this); + }, this); + }; + CIDMap.prototype.has = function (key) { + return getCID(key) in this.values; + }; + CIDMap.prototype.get = function (key) { + var obj = this.values[getCID(key)]; + return obj && obj.value; + }; + CIDMap.prototype.clear = function () { + return this.values = {}; + }; + Object.defineProperty(CIDMap.prototype, 'size', { + get: function () { + var size = 0; + helpers.each(this.values, function () { + size++; + }); + return size; + } + }); + } + module.exports = CIDMap; +}); +/*can-util@3.10.18#dom/events/make-mutation-event/make-mutation-event*/ +define('can-util/dom/events/make-mutation-event/make-mutation-event', [ + 'require', + 'exports', + 'module', + 'can-util/dom/events/events', + 'can-util/dom/data/data', + 'can-globals/mutation-observer/mutation-observer', + 'can-util/dom/dispatch/dispatch', + 'can-util/dom/mutation-observer/document/document', + 'can-globals/document/document', + 'can-cid/map/map', + 'can-util/js/string/string', + 'can-util/dom/is-of-global-document/is-of-global-document' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var events = require('can-util/dom/events/events'); + var domData = require('can-util/dom/data/data'); + var getMutationObserver = require('can-globals/mutation-observer/mutation-observer'); + var domDispatch = require('can-util/dom/dispatch/dispatch'); + var mutationDocument = require('can-util/dom/mutation-observer/document/document'); + var getDocument = require('can-globals/document/document'); + var CIDMap = require('can-cid/map/map'); + var string = require('can-util/js/string/string'); + require('can-util/dom/is-of-global-document/is-of-global-document'); + module.exports = function (specialEventName, mutationNodesProperty) { + var originalAdd = events.addEventListener, originalRemove = events.removeEventListener; + events.addEventListener = function (eventName) { + if (eventName === specialEventName && getMutationObserver()) { + var documentElement = getDocument().documentElement; + var specialEventData = domData.get.call(documentElement, specialEventName + 'Data'); + if (!specialEventData) { + specialEventData = { + handler: function (mutatedNode) { + if (specialEventData.nodeIdsRespondingToInsert.has(mutatedNode)) { + domDispatch.call(mutatedNode, specialEventName, [], false); + specialEventData.nodeIdsRespondingToInsert.delete(mutatedNode); + } + }, + nodeIdsRespondingToInsert: new CIDMap() + }; + mutationDocument['on' + string.capitalize(mutationNodesProperty)](specialEventData.handler); + domData.set.call(documentElement, specialEventName + 'Data', specialEventData); + } + if (this.nodeType !== 11) { + var count = specialEventData.nodeIdsRespondingToInsert.get(this) || 0; + specialEventData.nodeIdsRespondingToInsert.set(this, count + 1); + } + } + return originalAdd.apply(this, arguments); + }; + events.removeEventListener = function (eventName) { + if (eventName === specialEventName && getMutationObserver()) { + var documentElement = getDocument().documentElement; + var specialEventData = domData.get.call(documentElement, specialEventName + 'Data'); + if (specialEventData) { + var newCount = specialEventData.nodeIdsRespondingToInsert.get(this) - 1; + if (newCount) { + specialEventData.nodeIdsRespondingToInsert.set(this, newCount); + } else { + specialEventData.nodeIdsRespondingToInsert.delete(this); + } + if (!specialEventData.nodeIdsRespondingToInsert.size) { + mutationDocument['off' + string.capitalize(mutationNodesProperty)](specialEventData.handler); + domData.clean.call(documentElement, specialEventName + 'Data'); + } + } + } + return originalRemove.apply(this, arguments); + }; + }; + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-util@3.10.18#dom/events/inserted/inserted*/ +define('can-util/dom/events/inserted/inserted', [ + 'require', + 'exports', + 'module', + 'can-util/dom/events/make-mutation-event/make-mutation-event' +], function (require, exports, module) { + 'use strict'; + var makeMutationEvent = require('can-util/dom/events/make-mutation-event/make-mutation-event'); + makeMutationEvent('inserted', 'addedNodes'); +}); +/*can-util@3.10.18#dom/attr/attr*/ +define('can-util/dom/attr/attr', [ + 'require', + 'exports', + 'module', + 'can-util/js/set-immediate/set-immediate', + 'can-globals/document/document', + 'can-globals/global/global', + 'can-util/dom/is-of-global-document/is-of-global-document', + 'can-util/dom/data/data', + 'can-util/dom/contains/contains', + 'can-util/dom/events/events', + 'can-util/dom/dispatch/dispatch', + 'can-globals/mutation-observer/mutation-observer', + 'can-util/js/each/each', + 'can-types', + 'can-util/js/diff/diff', + 'can-util/dom/events/attributes/attributes', + 'can-util/dom/events/inserted/inserted' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + var setImmediate = require('can-util/js/set-immediate/set-immediate'); + var getDocument = require('can-globals/document/document'); + var global = require('can-globals/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 getMutationObserver = require('can-globals/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'); + require('can-util/dom/events/inserted/inserted'); + 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 = getMutationObserver(); + 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 }); + } + } + }, _findOptionToSelect = function (parent, value) { + var child = parent.firstChild; + while (child) { + if (child.nodeName === 'OPTION' && value === child.value) { + return child; + } + if (child.nodeName === 'OPTGROUP') { + var groupChild = _findOptionToSelect(child, value); + if (groupChild) { + return groupChild; + } + } + child = child.nextSibling; + } + }, setChildOptions = function (el, value) { + var option; + if (value != null) { + option = _findOptionToSelect(el, value); + } + if (option) { + option.selected = true; + } else { + el.selectedIndex = -1; + } + }, forEachOption = function (parent, fn) { + var child = parent.firstChild; + while (child) { + if (child.nodeName === 'OPTION') { + fn(child); + } + if (child.nodeName === 'OPTGROUP') { + forEachOption(child, fn); + } + child = child.nextSibling; + } + }, collectSelectedOptions = function (parent) { + var selectedValues = []; + forEachOption(parent, function (option) { + if (option.selected) { + selectedValues.push(option.value); + } + }); + return selectedValues; + }, markSelectedOptions = function (parent, values) { + forEachOption(parent, function (option) { + option.selected = values.indexOf(option.value) !== -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'); + var docEl = this.ownerDocument.documentElement; + var element = this; + function focusTask() { + if (val) { + element.focus(); + } else { + element.blur(); + } + } + if (cur !== val) { + if (!domContains.call(docEl, element)) { + var initialSetHandler = function () { + domEvents.removeEventListener.call(element, 'inserted', initialSetHandler); + focusTask(); + }; + domEvents.addEventListener.call(element, 'inserted', initialSetHandler); + } else { + types.queueTask([ + focusTask, + 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 () { + return collectSelectedOptions(this); + }, + set: function (values) { + values = values || []; + markSelectedOptions(this, values); + 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) && getMutationObserver(); + 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 && namespaces[attr[0]]) { + 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 (!getMutationObserver()) { + 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 (!getMutationObserver() && 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; + }(), require, exports, module)); +}); +/*can-util@3.10.18#dom/mutate/mutate*/ +define('can-util/dom/mutate/mutate', [ + 'require', + 'exports', + 'module', + 'can-util/js/make-array/make-array', + 'can-util/js/set-immediate/set-immediate', + 'can-cid', + 'can-globals/mutation-observer/mutation-observer', + 'can-util/dom/child-nodes/child-nodes', + 'can-util/dom/contains/contains', + 'can-util/dom/dispatch/dispatch', + 'can-globals/document/document', + 'can-util/dom/data/data' +], function (require, exports, module) { + (function (global, require, exports, module) { + 'use strict'; + 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-globals/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 getDocument = require('can-globals/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 = getDocument() || firstElement.ownerDocument || firstElement; + var root = doc.contains ? doc : doc.documentElement; + 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 = getDocument() || firstElement.ownerDocument || firstElement; + var root = doc.contains ? doc : doc.documentElement; + 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'); + } + }; + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-view-target@3.1.5#can-view-target*/ +define('can-view-target', [ + 'require', + 'exports', + 'module', + 'can-util/dom/child-nodes/child-nodes', + 'can-util/dom/attr/attr', + 'can-util/js/each/each', + 'can-util/js/make-array/make-array', + 'can-globals/document/document', + 'can-util/dom/mutate/mutate', + 'can-namespace', + 'can-globals/mutation-observer/mutation-observer' +], function (require, exports, module) { + (function (global, require, exports, module) { + var childNodes = require('can-util/dom/child-nodes/child-nodes'); + var domAttr = require('can-util/dom/attr/attr'); + var each = require('can-util/js/each/each'); + var makeArray = require('can-util/js/make-array/make-array'); + var getDocument = require('can-globals/document/document'); + var domMutate = require('can-util/dom/mutate/mutate'); + var namespace = require('can-namespace'); + var MUTATION_OBSERVER = require('can-globals/mutation-observer/mutation-observer'); + var processNodes = function (nodes, paths, location, document) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + frag.appendChild(processNode(node, paths, location.concat(i), document)); + } + return frag; + }, keepsTextNodes = typeof document !== 'undefined' && function () { + var testFrag = document.createDocumentFragment(); + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + testFrag.appendChild(div); + var cloned = testFrag.cloneNode(true); + return childNodes(cloned.firstChild).length === 2; + }(), clonesWork = typeof document !== 'undefined' && function () { + var el = document.createElement('a'); + el.innerHTML = ''; + var clone = el.cloneNode(true); + var works = clone.innerHTML === ''; + var MO, observer; + if (works) { + el = document.createDocumentFragment(); + el.appendChild(document.createTextNode('foo-bar')); + MO = MUTATION_OBSERVER(); + if (MO) { + observer = new MO(function () { + }); + observer.observe(document.documentElement, { + childList: true, + subtree: true + }); + clone = el.cloneNode(true); + observer.disconnect(); + } else { + clone = el.cloneNode(true); + } + return clone.childNodes.length === 1; + } + return works; + }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS; + var cloneNode = clonesWork ? function (el) { + return el.cloneNode(true); + } : function (node) { + var document = node.ownerDocument; + var copy; + if (node.nodeType === 1) { + if (node.namespaceURI !== 'http://www.w3.org/1999/xhtml' && namespacesWork && document.createElementNS) { + copy = document.createElementNS(node.namespaceURI, node.nodeName); + } else { + copy = document.createElement(node.nodeName); + } + } else if (node.nodeType === 3) { + copy = document.createTextNode(node.nodeValue); + } else if (node.nodeType === 8) { + copy = document.createComment(node.nodeValue); + } else if (node.nodeType === 11) { + copy = document.createDocumentFragment(); + } + if (node.attributes) { + var attributes = makeArray(node.attributes); + each(attributes, function (node) { + if (node && node.specified) { + domAttr.setAttribute(copy, node.nodeName || node.name, node.nodeValue || node.value); + } + }); + } + if (node && node.firstChild) { + var child = node.firstChild; + while (child) { + copy.appendChild(cloneNode(child)); + child = child.nextSibling; + } + } + return copy; + }; + function processNode(node, paths, location, document) { + var callback, loc = location, nodeType = typeof node, el, p, i, len; + var getCallback = function () { + if (!callback) { + callback = { + path: location, + callbacks: [] + }; + paths.push(callback); + loc = []; + } + return callback; + }; + if (nodeType === 'object') { + if (node.tag) { + if (namespacesWork && node.namespace) { + el = document.createElementNS(node.namespace, node.tag); + } else { + el = document.createElement(node.tag); + } + if (node.attrs) { + for (var attrName in node.attrs) { + var value = node.attrs[attrName]; + if (typeof value === 'function') { + getCallback().callbacks.push({ callback: value }); + } else { + domAttr.setAttribute(el, attrName, value); + } + } + } + if (node.attributes) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.attributes[i] }); + } + } + if (node.children && node.children.length) { + if (callback) { + p = callback.paths = []; + } else { + p = paths; + } + el.appendChild(processNodes(node.children, p, loc, document)); + } + } else if (node.comment) { + el = document.createComment(node.comment); + if (node.callbacks) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.callbacks[i] }); + } + } + } + } else if (nodeType === 'string') { + el = document.createTextNode(node); + } else if (nodeType === 'function') { + if (keepsTextNodes) { + el = document.createTextNode(''); + getCallback().callbacks.push({ callback: node }); + } else { + el = document.createComment('~'); + getCallback().callbacks.push({ + callback: function () { + var el = document.createTextNode(''); + domMutate.replaceChild.call(this.parentNode, el, this); + return node.apply(el, arguments); + } + }); + } + } + return el; + } + function getCallbacks(el, pathData, elementCallbacks) { + var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, child = el, pathLength = path ? path.length : 0, pathsLength = paths ? paths.length : 0; + for (var i = 0; i < pathLength; i++) { + child = child.childNodes.item(path[i]); + } + for (i = 0; i < pathsLength; i++) { + getCallbacks(child, paths[i], elementCallbacks); + } + elementCallbacks.push({ + element: child, + callbacks: callbacks + }); + } + function hydrateCallbacks(callbacks, args) { + var len = callbacks.length, callbacksLength, callbackElement, callbackData; + for (var i = 0; i < len; i++) { + callbackData = callbacks[i]; + callbacksLength = callbackData.callbacks.length; + callbackElement = callbackData.element; + for (var c = 0; c < callbacksLength; c++) { + callbackData.callbacks[c].callback.apply(callbackElement, args); + } + } + } + function makeTarget(nodes, doc) { + var paths = []; + var frag = processNodes(nodes, paths, [], doc || getDocument()); + return { + paths: paths, + clone: frag, + hydrate: function () { + var cloned = cloneNode(this.clone); + var args = makeArray(arguments); + var callbacks = []; + for (var i = 0; i < paths.length; i++) { + getCallbacks(cloned, paths[i], callbacks); + } + hydrateCallbacks(callbacks, args); + return cloned; + } + }; + } + makeTarget.keepsTextNodes = keepsTextNodes; + makeTarget.cloneNode = cloneNode; + namespace.view = namespace.view || {}; + module.exports = namespace.view.target = makeTarget; + }(function () { + return this; + }(), require, exports, module)); +}); +/*[global-shim-end]*/ +(function(global) { // jshint ignore:line + global._define = global.define; + global.define = global.define.orig; +} +)(typeof self == "object" && self.Object == Object ? self : window); \ No newline at end of file