Skip to content

Commit

Permalink
properly strip comments/text nodes
Browse files Browse the repository at this point in the history
partially fixes #81 (except named templates)
  • Loading branch information
rniemeyer committed Jan 8, 2014
1 parent ca9225c commit 603902a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "knockout-sortable",
"version": "0.8.4",
"version": "0.8.5",
"main": "./build/knockout-sortable.min.js",
"ignore": [
"examples",
Expand Down
8 changes: 4 additions & 4 deletions build/knockout-sortable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// knockout-sortable 0.8.4 | (c) 2013 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
// knockout-sortable 0.8.5 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
;(function(factory) {
if (typeof define === "function" && define.amd) {
// AMD anonymous module
Expand Down Expand Up @@ -88,9 +88,9 @@
startActual, updateActual;

//remove leading/trailing non-elements from anonymous templates
ko.utils.arrayForEach(element.childNodes, function(node) {
if (node && node.nodeType !== 1) {
node.parentNode.removeChild(node);
$element.contents().each(function() {
if (this && this.nodeType !== 1) {
element.removeChild(this);
}
});

Expand Down
4 changes: 2 additions & 2 deletions build/knockout-sortable.min.js

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

2 changes: 2 additions & 0 deletions examples/singleList.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<div id="main">
<h3>Tasks</h3>
<div class="container" data-bind="sortable: tasks">
<!-- leading comment -->
<div class="item">
<span data-bind="visible: !$root.isTaskSelected($data)">
<a href="#" data-bind="text: name, click: $root.selectedTask"></a>
Expand All @@ -82,6 +83,7 @@ <h3>Tasks</h3>
<input data-bind="value: name, event: { blur: $root.clearTask }" />
</span>
</div>
<!-- trailing comment -->
</div>
<a href="#" data-bind="click: addTask">Add Task</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "knockout-sortable",
"version": "0.8.4",
"version": "0.8.5",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "0.x.x",
Expand Down
6 changes: 3 additions & 3 deletions src/knockout-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@
startActual, updateActual;

//remove leading/trailing non-elements from anonymous templates
ko.utils.arrayForEach(element.childNodes, function(node) {
if (node && node.nodeType !== 1) {
node.parentNode.removeChild(node);
$element.contents().each(function() {
if (this && this.nodeType !== 1) {
element.removeChild(this);
}
});

Expand Down

0 comments on commit 603902a

Please sign in to comment.