can-dom-mutate
Advanced tools
Comparing version 2.0.3 to 2.0.4
'use strict'; | ||
var globals = require('can-globals'); | ||
var getRoot = require('can-globals/global/global'); | ||
@@ -53,11 +54,2 @@ var getMutationObserver = require('can-globals/mutation-observer/mutation-observer'); | ||
} | ||
/* | ||
function toMutationEvents (nodes) { | ||
var events = []; | ||
for (var i = 0, length = nodes.length; i < length; i++) { | ||
events.push({target: nodes[i]}); | ||
} | ||
return events; | ||
} | ||
*/ | ||
@@ -133,31 +125,6 @@ function getDocumentListeners (target, key) { | ||
} | ||
/* | ||
function flushRecords(){ | ||
if(recordsAndCallbacks === null) { | ||
return; | ||
} | ||
var safeBatch = recordsAndCallbacks; | ||
recordsAndCallbacks = null; | ||
var batchCount = safeBatch.length; | ||
for (var i = 0; i < batchCount; i++) { | ||
var batchData = safeBatch[i]; | ||
flushCallbacks(batchData.callbacks, batchData.arg); | ||
} | ||
} | ||
function flushAsync(callbacks, arg) { | ||
if(recordsAndCallbacks === null) { | ||
recordsAndCallbacks = [{arg: arg, callbacks: callbacks}]; | ||
nextTick(flushRecords); | ||
} else { | ||
recordsAndCallbacks.push({arg: arg, callbacks: callbacks}); | ||
} | ||
} | ||
*/ | ||
function dispatch(getListeners, targetKey) { | ||
return function dispatchEvents(event) { | ||
var targetListeners = getListeners(event.target, targetKey); | ||
@@ -168,3 +135,2 @@ | ||
} | ||
}; | ||
@@ -206,2 +172,3 @@ } | ||
if (observerData.observingCount === 0) { | ||
globals.onKeyValue('MutationObserver', setupObserver); | ||
setupObserver(); | ||
@@ -220,2 +187,3 @@ } | ||
deleteRelatedData(target, observerKey); | ||
globals.offKeyValue('MutationObserver', setupObserver); | ||
} | ||
@@ -225,65 +193,3 @@ } | ||
} | ||
/* | ||
function handleTreeMutations(mutations) { | ||
// in IE11, if the document is being removed | ||
// (such as when an iframe is added and then removed) | ||
// all of the global constructors will not exist | ||
// If this happens before a tree mutation is handled, | ||
// this will throw an `Object expected` error. | ||
if (typeof Set === "undefined") { return; } | ||
if(this.flushing === true) { | ||
this.mutations.push.apply(this.mutations, mutations); | ||
return; | ||
} | ||
this.flushing = true; | ||
this.mutations = [].slice.call(mutations); | ||
var mutation; | ||
var mutationCount = mutations.length; | ||
var added = new Set(), removed = new Set(); | ||
while(mutation = this.mutations.shift()) { | ||
var removedCount = mutation.removedNodes.length; | ||
for (var r = 0; r < removedCount; r++) { | ||
// get what already isn't in `removed` | ||
var newRemoved = util.addToSet( getAllNodes(mutation.removedNodes[r]), removed); | ||
dispatchRemoval( newRemoved.map(toMutationEvent), null, true, flushCallbacks ); | ||
} | ||
var addedCount = mutation.addedNodes.length; | ||
for (var a = 0; a < addedCount; a++) { | ||
var newAdded = util.addToSet( getAllNodes(mutation.addedNodes[a]), added); | ||
dispatchInsertion( newAdded.map(toMutationEvent), null, true, flushCallbacks ); | ||
} | ||
} | ||
this.flushing = false; | ||
//dispatchRemoval( toMutationEvents( canReflect.toArray(removed) ), null, true, flushCallbacks ); | ||
//dispatchInsertion( toMutationEvents( canReflect.toArray(added) ), null, true, flushCallbacks ); | ||
} | ||
function handleAttributeMutations(mutations) { | ||
var mutationCount = mutations.length; | ||
for (var m = 0; m < mutationCount; m++) { | ||
var mutation = mutations[m]; | ||
if (mutation.type === 'attributes') { | ||
var node = mutation.target; | ||
var attributeName = mutation.attributeName; | ||
var oldValue = mutation.oldValue; | ||
dispatchAttributeChange([{ | ||
target: node, | ||
attributeName: attributeName, | ||
oldValue: oldValue | ||
}], null, true, flushCallbacks); | ||
} | ||
} | ||
} | ||
*/ | ||
var treeMutationConfig = { | ||
@@ -465,6 +371,2 @@ subtree: true, | ||
var FLUSHING_MUTATIONS = []; | ||
@@ -471,0 +373,0 @@ var IS_FLUSHING = false; |
@@ -182,4 +182,2 @@ 'use strict'; | ||
//mutate.isConnected = isConnected; | ||
module.exports = namespace.domMutateNode = domMutate.node = mutate; |
{ | ||
"name": "can-dom-mutate", | ||
"description": "Dispatch and listen for DOM mutations", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "DoneJS Team", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
75680
22
1743