Skip to content

Commit

Permalink
Use can-dom-mutate and drop can-util
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejewski committed Dec 29, 2017
1 parent 62d544f commit 9e959a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions can-view-target.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* jshint maxdepth:7 */
/* jshint latedef:false */
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 domMutate = require('can-dom-mutate/node');
var namespace = require('can-namespace');
var MUTATION_OBSERVER = require('can-globals/mutation-observer/mutation-observer');

Expand Down Expand Up @@ -33,7 +29,7 @@ var processNodes = function(nodes, paths, location, document){

var cloned = testFrag.cloneNode(true);

return childNodes(cloned.firstChild).length === 2;
return cloned.firstChild.childNodes.length === 2;
})(),
clonesWork = typeof document !== "undefined" && (function(){
// Since html5shiv is required to support custom elements, assume cloning
Expand Down Expand Up @@ -110,12 +106,13 @@ var cloneNode = clonesWork ?
}

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);
var attributes = node.attributes;
for (var i = 0; i < attributes.length; i++) {
var attribute = attributes[i];
if (attribute && attribute.specified) {
domMutate.setAttribute.call(copy, attribute.nodeName || attribute.name, attribute.nodeValue || attribute.value);
}
});
}
}

if(node && node.firstChild) {
Expand Down Expand Up @@ -165,7 +162,7 @@ function processNode(node, paths, location, document){
callback: value
});
} else {
domAttr.setAttribute(el, attrName, value);
domMutate.setAttribute.call(el, attrName, value);
}
}
}
Expand Down Expand Up @@ -264,7 +261,10 @@ function makeTarget(nodes, doc){
clone: frag,
hydrate: function(){
var cloned = cloneNode(this.clone);
var args = makeArray(arguments);
var args = [];
for (var a = 0, ref = args.length = arguments.length; a < ref; a++) {
args[a] = arguments[a];
} // see https://jsperf.com/nodelist-to-array

var callbacks = [];
for(var i = 0; i < paths.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"donejs"
],
"dependencies": {
"can-dom-mutate": "<2.0.0",
"can-globals": "<2.0.0",
"can-namespace": "1.0.0",
"can-util": "^3.10.9"
"can-namespace": "1.0.0"
},
"devDependencies": {
"bit-docs": "0.0.7",
Expand Down

0 comments on commit 9e959a9

Please sign in to comment.