Skip to content

Commit

Permalink
3.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbmeyer committed Jan 26, 2018
1 parent bc32900 commit 72f2367
Show file tree
Hide file tree
Showing 48 changed files with 6,770 additions and 0 deletions.
19 changes: 19 additions & 0 deletions dist/amd/can-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*can-util@3.11.0#can-util*/
define([
'require',
'exports',
'module',
'./js/deep-assign/deep-assign',
'./js/omit/omit',
'can-namespace',
'./dom/dom',
'./js/js'
], function (require, exports, module) {
var deepAssign = require('./js/deep-assign/deep-assign');
var omit = require('./js/omit/omit');
var namespace = require('can-namespace');
module.exports = deepAssign(namespace, require('./dom/dom'), omit(require('./js/js'), [
'cid',
'types'
]));
});
12 changes: 12 additions & 0 deletions dist/amd/dom/ajax/ajax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*can-util@3.11.0#dom/ajax/ajax*/
define([
'require',
'exports',
'module',
'can-log/dev',
'can-ajax'
], function (require, exports, module) {
'use strict';
var canDev = require('can-log/dev');
module.exports = require('can-ajax');
});
587 changes: 587 additions & 0 deletions dist/amd/dom/attr/attr.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions dist/amd/dom/child-nodes/child-nodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*can-util@3.11.0#dom/child-nodes/child-nodes*/
define(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;
});
29 changes: 29 additions & 0 deletions dist/amd/dom/class-name/class-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*can-util@3.11.0#dom/class-name/class-name*/
define(function (require, exports, module) {
'use strict';
var has = function (className) {
if (this.classList) {
return this.classList.contains(className);
} else {
return !!this.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
}
};
module.exports = {
has: has,
add: function (className) {
if (this.classList) {
this.classList.add(className);
} else if (!has.call(this, className)) {
this.className += ' ' + className;
}
},
remove: function (className) {
if (this.classList) {
this.classList.remove(className);
} else if (has.call(this, className)) {
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
this.className = this.className.replace(reg, ' ');
}
}
};
});
7 changes: 7 additions & 0 deletions dist/amd/dom/contains/contains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*can-util@3.11.0#dom/contains/contains*/
define(function (require, exports, module) {
'use strict';
module.exports = function (child) {
return this.contains(child);
};
});
43 changes: 43 additions & 0 deletions dist/amd/dom/data/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*can-util@3.11.0#dom/data/data*/
define([
'require',
'exports',
'module',
'can-dom-data-state',
'../mutation-observer/document/document'
], function (require, exports, module) {
'use strict';
var domDataState = require('can-dom-data-state');
var mutationDocument = require('../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;
}
};
});
13 changes: 13 additions & 0 deletions dist/amd/dom/dispatch/dispatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*can-util@3.11.0#dom/dispatch/dispatch*/
define([
'require',
'exports',
'module',
'../events/events'
], function (require, exports, module) {
'use strict';
var domEvents = require('../events/events');
module.exports = function () {
return domEvents.dispatch.apply(this, arguments);
};
});
14 changes: 14 additions & 0 deletions dist/amd/dom/document/document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*can-util@3.11.0#dom/document/document*/
define([
'require',
'exports',
'module',
'can-globals/document'
], function (require, exports, module) {
(function (global, require, exports, module) {
'use strict';
module.exports = require('can-globals/document');
}(function () {
return this;
}(), require, exports, module));
});
44 changes: 44 additions & 0 deletions dist/amd/dom/dom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*can-util@3.11.0#dom/dom*/
define([
'require',
'exports',
'module',
'./ajax/ajax',
'./attr/attr',
'./child-nodes/child-nodes',
'./class-name/class-name',
'./contains/contains',
'./data/data',
'./dispatch/dispatch',
'./document/document',
'./events/events',
'./frag/frag',
'./fragment/fragment',
'./is-of-global-document/is-of-global-document',
'./matches/matches',
'./mutate/mutate',
'./mutation-observer/mutation-observer'
], function (require, exports, module) {
(function (global, require, exports, module) {
'use strict';
module.exports = {
ajax: require('./ajax/ajax'),
attr: require('./attr/attr'),
childNodes: require('./child-nodes/child-nodes'),
className: require('./class-name/class-name'),
contains: require('./contains/contains'),
data: require('./data/data'),
dispatch: require('./dispatch/dispatch'),
document: require('./document/document'),
events: require('./events/events'),
frag: require('./frag/frag'),
fragment: require('./fragment/fragment'),
isOfGlobalDocument: require('./is-of-global-document/is-of-global-document'),
matches: require('./matches/matches'),
mutate: require('./mutate/mutate'),
mutationObserver: require('./mutation-observer/mutation-observer')
};
}(function () {
return this;
}(), require, exports, module));
});
66 changes: 66 additions & 0 deletions dist/amd/dom/events/attributes/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*can-util@3.11.0#dom/events/attributes/attributes*/
define([
'require',
'exports',
'module',
'../events',
'../../is-of-global-document/is-of-global-document',
'../../data/data',
'can-globals/mutation-observer',
'can-assign',
'../../dispatch/dispatch'
], function (require, exports, module) {
(function (global, require, exports, module) {
'use strict';
var events = require('../events');
var isOfGlobalDocument = require('../../is-of-global-document/is-of-global-document');
var domData = require('../../data/data');
var getMutationObserver = require('can-globals/mutation-observer');
var assign = require('can-assign');
var domDispatch = require('../../dispatch/dispatch');
var originalAdd = events.addEventListener, originalRemove = events.removeEventListener;
events.addEventListener = function (eventName) {
if (eventName === 'attributes') {
var MutationObserver = getMutationObserver();
if (isOfGlobalDocument(this) && MutationObserver) {
var 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));
});
85 changes: 85 additions & 0 deletions dist/amd/dom/events/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*can-util@3.11.0#dom/events/events*/
define([
'require',
'exports',
'module',
'can-globals/document',
'can-globals/is-browser-window',
'../../js/is-plain-object/is-plain-object',
'can-log/dev'
], function (require, exports, module) {
(function (global, require, exports, module) {
'use strict';
var getDocument = require('can-globals/document');
var isBrowserWindow = require('can-globals/is-browser-window');
var isPlainObject = require('../../js/is-plain-object/is-plain-object');
var fixSyntheticEventsOnDisabled = false;
var dev = require('can-log/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));
});
11 changes: 11 additions & 0 deletions dist/amd/dom/events/inserted/inserted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*can-util@3.11.0#dom/events/inserted/inserted*/
define([
'require',
'exports',
'module',
'../make-mutation-event/make-mutation-event'
], function (require, exports, module) {
'use strict';
var makeMutationEvent = require('../make-mutation-event/make-mutation-event');
makeMutationEvent('inserted', 'addedNodes');
});
Loading

0 comments on commit 72f2367

Please sign in to comment.