-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca8e727
commit 078d1a0
Showing
48 changed files
with
6,695 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/*can-util@3.11.2#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' | ||
])); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/*can-util@3.11.2#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'); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/*can-util@3.11.2#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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*can-util@3.11.2#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, ' '); | ||
} | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/*can-util@3.11.2#dom/contains/contains*/ | ||
define(function (require, exports, module) { | ||
'use strict'; | ||
module.exports = function (child) { | ||
return this.contains(child); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*can-util@3.11.2#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; | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/*can-util@3.11.2#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); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*can-util@3.11.2#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)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*can-util@3.11.2#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)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*can-util@3.11.2#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)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/*can-util@3.11.2#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)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/*can-util@3.11.2#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'); | ||
}); |
Oops, something went wrong.