From f57a59d76720985c98bc57a9b3bb43cd13406583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20La=CC=88nnenma=CC=88ki?= Date: Fri, 18 Nov 2011 14:51:54 +0200 Subject: [PATCH] console.log to clone jQuery objects before appending them. If the appended element was a child of another element it was removed from that element. This caused console.logging a child element to remove it from the parent. --- spec/jasmine/console_log/console_log.yml | 2 +- spec/jasmine/console_log/console_log_spec.js | 7 +++++++ vendor/assets/javascripts/prolog.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/jasmine/console_log/console_log.yml b/spec/jasmine/console_log/console_log.yml index 7a2453e..0ceafe5 100644 --- a/spec/jasmine/console_log/console_log.yml +++ b/spec/jasmine/console_log/console_log.yml @@ -1,5 +1,5 @@ - src_files: + - spec/javascripts/support/jquery-1.6.2.min.js - spec/jasmine/console_log/console_log.js spec_files: diff --git a/spec/jasmine/console_log/console_log_spec.js b/spec/jasmine/console_log/console_log_spec.js index 471396c..90b4a26 100644 --- a/spec/jasmine/console_log/console_log_spec.js +++ b/spec/jasmine/console_log/console_log_spec.js @@ -3,5 +3,12 @@ describe('console.log', function() { console.log("hello"); expect(success).toEqual(1); }); + + it("wont eat my precious jqueries", function() { + var d = $('
b
'); + expect(d.find('#inner').length).toBe(1); + console.log(d.find('#inner')); + expect(d.find('#inner').length).toBe(1); + }); }); diff --git a/vendor/assets/javascripts/prolog.js b/vendor/assets/javascripts/prolog.js index 2fd358b..8fe9b77 100644 --- a/vendor/assets/javascripts/prolog.js +++ b/vendor/assets/javascripts/prolog.js @@ -5,7 +5,7 @@ log: function(data) { var dump, useJsDump; if (typeof jQuery !== 'undefined' && data instanceof jQuery) { - return JHW.log(style_html($("
").append(data).html(), { + return JHW.log(style_html($("
").append(data.clone()).html(), { indent_size: 2 })); } else {