console.log to clone jQuery objects before appending them. #82

Merged
leolannenmaki merged 2 commits from master into master 2011-11-21 18:56:49 +00:00
4 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,5 @@
src_files:
- spec/javascripts/support/jquery-1.6.2.min.js
- spec/jasmine/console_log/console_log.js
spec_files:

View File

@ -3,5 +3,12 @@ describe('console.log', function() {
console.log("hello");
expect(success).toEqual(1);
});
it("wont eat my precious jqueries", function() {
var d = $('<div><div id="inner">b</div></div>');
expect(d.find('#inner').length).toBe(1);
console.log(d.find('#inner'));
expect(d.find('#inner').length).toBe(1);
});
});

View File

@ -2,7 +2,7 @@ if window.JHW
window.console =
log: (data) ->
if typeof(jQuery) != 'undefined' && data instanceof jQuery
JHW.log(style_html($("<div />").append(data).html(), { indent_size: 2 }))
JHW.log(style_html($("<div />").append(data.clone()).html(), { indent_size: 2 }))
else
useJsDump = true

View File

@ -5,7 +5,7 @@
log: function(data) {
var dump, useJsDump;
if (typeof jQuery !== 'undefined' && data instanceof jQuery) {
return JHW.log(style_html($("<div />").append(data).html(), {
return JHW.log(style_html($("<div />").append(data.clone()).html(), {
indent_size: 2
}));
} else {