Skip to content

Commit

Permalink
marginal speed improvement, re. #37
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmhunt committed Dec 24, 2015
1 parent 7b3c9ac commit 00e0340
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
12 changes: 7 additions & 5 deletions dist/knockout-fast-foreach.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Knockout Fast Foreach v0.6.0 (2015-12-17T02:29:56.923Z)
Knockout Fast Foreach v0.6.0 (2015-12-24T03:08:52.576Z)
By: Brian M Hunt (C) 2015 | License: MIT
Adds `fastForEach` to `ko.bindingHandlers`.
Expand Down Expand Up @@ -367,12 +367,14 @@ FastForEach.prototype.deleted = function (changeItem) {

// removes a set of nodes from the DOM
FastForEach.prototype.removeNodes = function (nodes) {
if (!nodes.length) {
return;
}
if (!nodes.length) { return; }

var removeFn = function () {
ko.utils.arrayForEach(nodes, function (n) { ko.removeNode(n); });
var parent = nodes[0].parentNode;
for (var i = nodes.length - 1; i >= 0; --i) {
ko.cleanNode(nodes[i]);
parent.removeChild(nodes[i]);
}
};

if (this.beforeRemove) {
Expand Down
2 changes: 1 addition & 1 deletion dist/knockout-fast-foreach.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
var gulp = require('gulp'),
yaml = require('js-yaml'),
fs = require('fs'),
config = yaml.safeLoad(fs.readFileSync('./config.yaml', 'utf8')),
plugins = require('gulp-load-plugins')();
yaml = require('js-yaml'),
fs = require('fs'),
config = yaml.safeLoad(fs.readFileSync('./config.yaml', 'utf8')),
plugins = require('gulp-load-plugins')();

// from https://github.com/ikari-pl/gulp-tag-version
// function inc(importance) {
Expand Down Expand Up @@ -41,4 +41,8 @@ gulp.task('js', function () {
.pipe(gulp.dest('./dist'));
});

gulp.task('watch', function () {
gulp.watch('./index.js', ['js'])
})

gulp.task('default', ['js'])
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,14 @@ FastForEach.prototype.deleted = function (changeItem) {

// removes a set of nodes from the DOM
FastForEach.prototype.removeNodes = function (nodes) {
if (!nodes.length) {
return;
}
if (!nodes.length) { return; }

var removeFn = function () {
ko.utils.arrayForEach(nodes, function (n) { ko.removeNode(n); });
var parent = nodes[0].parentNode;
for (var i = nodes.length - 1; i >= 0; --i) {
ko.cleanNode(nodes[i]);
parent.removeChild(nodes[i]);
}
};

if (this.beforeRemove) {
Expand Down

0 comments on commit 00e0340

Please sign in to comment.