can.view and jquery 1.9.0 throws an error #237

Merged
merged 3 commits into from Jan 25, 2013

Conversation

Projects
None yet
5 participants
@daffl
Contributor

daffl commented Jan 25, 2013

The following line raises an error :

can.view("player-template", {playlist:{name:"xx","id":1}, name:"ddd",  song:null})

An error :
Uncaught TypeError: Object [object Object] has no method 'createDocumentFragment'

A template:

<script type="text/ejs" id="player-template">
<div id="player" class="container">
    <div class="navbar">
      <div class="navbar-inner">
        <div class="container">
                <ul class="nav pull-right player-controls">
                  <li class="name"><div class="song-progress"></div><span class="playlist"><%= playlist.name %></span> <span class="song"><% if(song){ %><% song.Album.Artist.name %> - <%= song.Song.name %><% } %></span></li>
                  <li class="play"><a class="btn" href="javascript://" ><i class="icon-play"></i> Play</a></li>
                  <li class="pause"><a class="btn" href="javascript://" ><i class="icon-pause"></i> Pause</a></li>
                  <li class="next-song"><a class="btn" href="javascript://"><i class="icon-forward"></i> Next Song</a></li>
                  <li class="volume"><div class="volume-control hide"><div class="volume-slider-vertical" ></div></div><a class="btn" href="javascript://"><i class="icon-volume-up"></i></a>
                  <li class="volume-off"><a class="btn" href="javascript://"><i class="icon-volume-off"></i></a>
                  <li class="like"><a class="btn" href="javascript://"><i class="icon-thumbs-up"></i></a>
                  <li class="dislike"><a class="btn" href="javascript://"><i class="icon-thumbs-down"></i></a>
                  <li class="share"><a class="btn" href="javascript://"><i class="icon-share"></i> Share</a>
                </ul>
            </div>
        </div>
    </div>
</div>
</script>

@ghost ghost assigned daffl Jan 17, 2013

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jan 17, 2013

Contributor

Yes, CanJS currently doesn't work with jQuery 1.9. They've done some weird changes working with document fragments. We'll try and make it work with the 1.1.4 release.

Contributor

daffl commented Jan 17, 2013

Yes, CanJS currently doesn't work with jQuery 1.9. They've done some weird changes working with document fragments. We'll try and make it work with the 1.1.4 release.

@aloise

This comment has been minimized.

Show comment
Hide comment
@aloise

aloise Jan 17, 2013

I see. Thank you !

aloise commented Jan 17, 2013

I see. Thank you !

@rjgotten

This comment has been minimized.

Show comment
Hide comment
@rjgotten

rjgotten Jan 18, 2013

We'll try and make it work with the 1.1.4 release.

Not sure how far along you are for a solution, but FYI; you should simply be using the new jQuery.parseHtml function to parse HTML strings into jQuery-wrapped DOM element collections.

Should you really need document fragments instead of element collections, then you can use the following trick:

var node = jQuery.parseHtml( html )[0];
var fragment = node && node.parentNode;
return fragment;

jQuery has a unit test in place which guarantees that the parentNode of the elements in the collection returned by jQuery.parseHtml is a document fragment.

We'll try and make it work with the 1.1.4 release.

Not sure how far along you are for a solution, but FYI; you should simply be using the new jQuery.parseHtml function to parse HTML strings into jQuery-wrapped DOM element collections.

Should you really need document fragments instead of element collections, then you can use the following trick:

var node = jQuery.parseHtml( html )[0];
var fragment = node && node.parentNode;
return fragment;

jQuery has a unit test in place which guarantees that the parentNode of the elements in the collection returned by jQuery.parseHtml is a document fragment.

@ghost ghost assigned amcdnl Jan 18, 2013

@ghost ghost assigned daffl Jan 25, 2013

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 25, 2013

Contributor

We can't use try catch here.

Contributor

justinbmeyer commented on 39c4cd9 Jan 25, 2013

We can't use try catch here.

daffl added a commit that referenced this pull request Jan 25, 2013

@daffl daffl merged commit 279583b into master Jan 25, 2013

1 check passed

default The Travis build passed
Details

@daffl daffl deleted the jquery-1.9.0 branch Jan 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment