From b5220adbbcbb6216af176fa38c626aca53ec8d0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Tue, 5 Sep 2006 17:58:22 +0000 Subject: [PATCH] Modified example for css(String) as proposed in the list (concerning camlCase for dashed properties like font-weight); Modified test to cache test fixture instead of reloading it, should make the test suite run faster --- build/test/js/test.js | 21 +++++++++------------ src/jquery/jquery.js | 13 +++++++++++++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/build/test/js/test.js b/build/test/js/test.js index 1a47519..3f5030e 100644 --- a/build/test/js/test.js +++ b/build/test/js/test.js @@ -1,18 +1,13 @@ var queue = []; var blocking = false; +var fixture; function reset() { - synchronize(function() { - blocking = true; - $.get('index.html', function(content) { - var div = $(document.createElement('div')).html(content) - // search for main div - .find('[@id=main]').html(); - $('#main').html(div); - blocking = false; - process(); - }); - }); + if(fixture) { + $("#main").html(fixture); + } else { + fixture = $("#main").html(); + } } function synchronize(callback) { @@ -31,10 +26,11 @@ function process() { } function runTests(files) { + var fixture = null; + reset(); var startTime = new Date(); for( var i=0; i < files.length; i++) { runTest( files, i ); - reset(); } synchronize(function() { var runTime = new Date() - startTime; @@ -91,6 +87,7 @@ function runTest( files, num ) { document.getElementById("tests").appendChild( li ); Test = []; + reset(); blocking = false; process(); }); diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 98825c3..feb71e4 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -466,6 +466,17 @@ jQuery.fn = jQuery.prototype = { * @example $("p").css("color"); * @before

Test Paragraph.

* @result red + * @desc Retrieves the color style of the first paragraph + * + * @example $("p").css("fontWeight"); + * @before

Test Paragraph.

+ * @result bold + * @desc Retrieves the font-weight style of the first paragraph. + * Note that for all style properties with a dash (like 'font-weight'), you have to + * write it in camelCase. In other words: Every time you have a '-' in a + * property, remove it and replace the next character with an uppercase + * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth, + * borderStyle, borderBottomWidth etc. * * @test ok( $('#foo').css("display") == 'block', 'Check for css property "display"'); * @@ -502,6 +513,8 @@ jQuery.fn = jQuery.prototype = { * @example $("p").css("color","red"); * @before

Test Paragraph.

* @result

Test Paragraph.

+ * @desc Changes the color of all paragraphs to red + * * * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible'); * @test $('#foo').css('display', 'none'); -- 1.7.10.4