Skip to content

Commit

Permalink
Fix error in fixUpContinuousNodeArray when using jquery.tmpl
Browse files Browse the repository at this point in the history
The `shift` method does not exist on jQuery objects. However, the `splice` method does exist. Previously, `splice(0,1)` was used as of knockout#144 but was replaced with `shift()` in [this commit](knockout@7c99a94#diff-2b4ca49d4bb0a774c4d4c1672d7aa781R235).

A workaround can be found [on StackOverflow:](http://stackoverflow.com/questions/6515544/how-to-pop-or-shift-from-jquery-set)

```
(function( $ ) {
    $.fn.pop = function() {
        var top = this.get(-1);
        this.splice(this.length-1,1);
        return top;
    };

    $.fn.shift = function() {
        var bottom = this.get(0);
        this.splice(0,1);
        return bottom;
    };
})( jQuery );
```
  • Loading branch information
Scott Smerchek committed Sep 2, 2014
1 parent ad2c376 commit 8b3c402
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.js
Expand Up @@ -232,7 +232,7 @@ ko.utils = (function () {

// Rule [A]
while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode)
continuousNodeArray.shift();
continuousNodeArray.splice(0, 1);

// Rule [B]
if (continuousNodeArray.length > 1) {
Expand Down

0 comments on commit 8b3c402

Please sign in to comment.