Browse files

decoupling styles retrieval from the attr method

  • Loading branch information...
1 parent 9476530 commit d7d908b05a442745c1a90728805b74db0a7921cf @brandonaaron brandonaaron committed Mar 22, 2009
Showing with 4,177 additions and 257 deletions.
  1. +1 −0 Makefile
  2. +1 −0 build.xml
  3. +65 −0 speed/benchmarker.css
  4. +181 −0 speed/benchmarker.js
  5. +72 −0 speed/index.html
  6. +3,549 −0 speed/jquery-basis.js
  7. +15 −164 src/attributes.js
  8. +205 −0 src/css.js
  9. +4 −4 src/fx.js
  10. +0 −5 src/support.js
  11. +1 −0 test/index.html
  12. +0 −83 test/unit/attributes.js
  13. +82 −0 test/unit/css.js
  14. +1 −1 test/unit/fx.js
View
1 Makefile
@@ -16,6 +16,7 @@ BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/manipulation.js\
${SRC_DIR}/event.js\
${SRC_DIR}/support.js\
+ ${SRC_DIR}/css.js\
${SRC_DIR}/ajax.js\
${SRC_DIR}/fx.js\
${SRC_DIR}/offset.js\
View
1 build.xml
@@ -60,6 +60,7 @@
<fileset dir="${SRC_DIR}" includes="manipulation.js" />
<fileset dir="${SRC_DIR}" includes="event.js" />
<fileset dir="${SRC_DIR}" includes="support.js" />
+ <fileset dir="${SRC_DIR}" includes="css.js" />
<fileset dir="${SRC_DIR}" includes="ajax.js" />
<fileset dir="${SRC_DIR}" includes="fx.js" />
<fileset dir="${SRC_DIR}" includes="offset.js" />
View
65 speed/benchmarker.css
@@ -0,0 +1,65 @@
+
+ .dialog {
+ margin-bottom: 1em;
+ }
+ a.expand {
+ background: #e3e3e3;
+ }
+
+ div#time-test {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 62.5%;
+ }
+
+ td.test button {
+ float: right;
+ }
+
+ table {
+ border: 1px solid #000;
+ }
+
+ table td, table th {
+ border: 1px solid #000;
+ padding: 10px;
+ }
+
+ td.winner {
+ background-color: #cfc;
+ }
+
+ td.tie {
+ background-color: #ffc;
+ }
+
+ td.fail {
+ background-color: #f99;
+ font-weight: bold;
+ text-align: center;
+ }
+
+ tfoot td {
+ text-align: center;
+ }
+
+ #time-test {
+ margin: 1em 0;
+ padding: .5em;
+ background: #e3e3e3;
+ }
+ #time-taken {
+ font-weight: bold;
+ }
+
+ span.wins {
+ color: #330;
+ }
+
+ span.fails {
+ color: #900;
+ }
+
+ div.buttons {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ }
View
181 speed/benchmarker.js
@@ -0,0 +1,181 @@
+ jQuery.benchmarker.tests = [
+ // Selectors from:
+ // http://ejohn.org/blog/selectors-that-people-actually-use/
+ /*
+ // For Amazon.com
+ "#navAmazonLogo", "#navSwmSkedPop",
+ ".navbar", ".navGreeting",
+ "div", "table",
+ "img.navCrossshopTabCap", "span.navGreeting",
+ "#navbar table", "#navidWelcomeMsg span",
+ "div#navbar", "ul#navAmazonLogo",
+ "#navAmazonLogo .navAmazonLogoGatewayPanel", "#navidWelcomeMsg .navGreeting",
+ ".navbar .navAmazonLogoGatewayPanel", ".navbar .navGreeting",
+ "*",
+ "#navAmazonLogo li.navAmazonLogoGatewayPanel", "#navidWelcomeMsg span.navGreeting",
+ "a[name=top]", "form[name=site-search]",
+ ".navbar li", ".navbar span",
+ "[name=top]", "[name=site-search]",
+ "ul li", "a img",
+ "#navbar #navidWelcomeMsg", "#navbar #navSwmDWPop",
+ "#navbar ul li", "#navbar a img"
+ */
+ // For Yahoo.com
+ "#page", "#masthead", "#mastheadhd",
+ ".mastheadbd", ".first", ".on",
+ "div", "li", "a",
+ "div.mastheadbd", "li.first", "li.on",
+ "#page div", "#dtba span",
+ "div#page", "div#masthead",
+ "#page .mastheadbd", "#page .first",
+ ".outer_search_container .search_container", ".searchbox_container .inputtext",
+ "*",
+ "#page div.mastheadbd", "#page li.first",
+ "input[name=p]", "a[name=marketplace]",
+ ".outer_search_container div", ".searchbox_container span",
+ "[name=p]", "[name=marketplace]",
+ "ul li", "form input",
+ "#page #e2econtent", "#page #e2e"
+ ];
+
+ jQuery.fn.benchmark = function() {
+ this.each(function() {
+ try {
+ jQuery(this).parent().children("*:gt(1)").remove();
+ } catch(e) { }
+ })
+ // set # times to run the test in index.html
+ var times = parseInt(jQuery("#times").val());
+ jQuery.benchmarker.startingList = this.get();
+ benchmark(this.get(), times, jQuery.benchmarker.libraries);
+ }
+
+ jQuery(function() {
+ for(i = 0; i < jQuery.benchmarker.tests.length; i++) {
+ jQuery("tbody").append("<tr><td class='test'>" + jQuery.benchmarker.tests[i] + "</td></tr>");
+ }
+ jQuery("tbody tr:first-child").remove();
+ jQuery("td.test").before("<td><input type='checkbox' checked='checked' /></td>");
+ jQuery("button.runTests").bind("click", function() {
+ jQuery('td:has(input:checked) + td.test').benchmark();
+ });
+
+ jQuery("button.retryTies").bind("click", function() { jQuery("tr:has(td.tie) td.test").benchmark() })
+
+ jQuery("button.selectAll").bind("click", function() { jQuery("input[type=checkbox]").each(function() { this.checked = true }) })
+ jQuery("button.deselectAll").bind("click", function() { jQuery("input[type=checkbox]").each(function() { this.checked = false }) })
+
+ jQuery("#addTest").bind("click", function() {
+ jQuery("table").append("<tr><td><input type='checkbox' /></td><td><input type='text' /><button>Add</button></td></tr>");
+ jQuery("div#time-test > button").each(function() { this.disabled = true; })
+ jQuery("tbody tr:last button").bind("click", function() {
+ var td = jQuery(this).parent();
+ td.html("<button>-</button>" + jQuery(this).prev().val()).addClass("test");
+ jQuery("div#time-test > button").each(function() { this.disabled = false; })
+ jQuery("button", td).bind("click", function() { jQuery(this).parents("tr").remove(); })
+ })
+ })
+
+ var headers = jQuery.map(jQuery.benchmarker.libraries, function(i,n) {
+ var extra = n == 0 ? "basis - " : "";
+ return "<th>" + extra + i + "</th>"
+ }).join("");
+
+ jQuery("thead tr").append(headers);
+
+ var footers = "";
+ for(i = 0; i < jQuery.benchmarker.libraries.length; i++)
+ footers += "<th></th>"
+
+ var wlfooters = "";
+ for(i = 0; i < jQuery.benchmarker.libraries.length; i++)
+ wlfooters += "<td><span class='wins'>W</span> / <span class='fails'>F</span></th>"
+
+ jQuery("tfoot tr:first").append(footers);
+ jQuery("tfoot tr:last").append(wlfooters);
+
+ });
+
+ benchmark = function(list, times, libraries) {
+ if(list[0]) {
+ var times = times || 50;
+ var el = list[0];
+ var code = jQuery(el).text().replace(/^-/, "");
+ var timeArr = []
+ for(i = 0; i < times + 2; i++) {
+ var time = new Date()
+ try {
+ window[libraries[0]](code);
+ } catch(e) { }
+ timeArr.push(new Date() - time);
+ }
+ var diff = Math.sum(timeArr) - Math.max.apply( Math, timeArr )
+ - Math.min.apply( Math, timeArr );
+ try {
+ var libRes = window[libraries[0]](code);
+ var jqRes = jQuery(code);
+ if(((jqRes.length == 0) && (libRes.length != 0)) ||
+ (libRes.length > 0 && (jqRes.length == libRes.length)) ||
+ ((libraries[0] == "cssQuery" || libraries[0] == "jQuery") && code.match(/nth\-child/) && (libRes.length > 0)) ||
+ ((libraries[0] == "jQold") && jqRes.length > 0)) {
+ jQuery(el).parent().append("<td>" + Math.round(diff / times * 100) / 100 + "ms</td>");
+ } else {
+ jQuery(el).parent().append("<td class='fail'>FAIL</td>");
+ }
+ } catch(e) {
+ jQuery(el).parent().append("<td class='fail'>FAIL</td>");
+ }
+ setTimeout(benchmarkList(list, times, libraries), 100);
+ } else if(libraries[1]) {
+ benchmark(jQuery.benchmarker.startingList, times, libraries.slice(1));
+ } else {
+ jQuery("tbody tr").each(function() {
+ var winners = jQuery("td:gt(1)", this).min(2);
+ if(winners.length == 1) winners.addClass("winner");
+ else winners.addClass("tie");
+ });
+ setTimeout(count, 100);
+ }
+ }
+
+ function benchmarkList(list, times, libraries) {
+ return function() {
+ benchmark(list.slice(1), times, libraries);
+ }
+ }
+
+ function count() {
+ for(i = 3; i <= jQuery.benchmarker.libraries.length + 2 ; i++) {
+ var fails = jQuery("td:nth-child(" + i + ").fail").length;
+ var wins = jQuery("td:nth-child(" + i + ").winner").length;
+ jQuery("tfoot tr:first th:eq(" + (i - 1) + ")")
+ .html("<span class='wins'>" + wins + "</span> / <span class='fails'>" + fails + "</span>");
+ }
+ }
+
+
+ jQuery.fn.maxmin = function(tolerance, maxmin, percentage) {
+ tolerance = tolerance || 0;
+ var target = Math[maxmin].apply(Math, jQuery.map(this, function(i) {
+ var parsedNum = parseFloat(i.innerHTML.replace(/[^\.\d]/g, ""));
+ if(parsedNum || (parsedNum == 0)) return parsedNum;
+ }));
+ return this.filter(function() {
+ if( withinTolerance(parseFloat(this.innerHTML.replace(/[^\.\d]/g, "")), target, tolerance, percentage) ) return true;
+ })
+ }
+
+ jQuery.fn.max = function(tolerance, percentage) { return this.maxmin(tolerance, "max", percentage) }
+ jQuery.fn.min = function(tolerance, percentage) { return this.maxmin(tolerance, "min", percentage) }
+
+ function withinTolerance(number, target, tolerance, percentage) {
+ if(percentage) { var high = target + ((tolerance / 100) * target); var low = target - ((tolerance / 100) * target); }
+ else { var high = target + tolerance; var low = target - tolerance; }
+ if(number >= low && number <= high) return true;
+ }
+
+ Math.sum = function(arr) {
+ var sum = 0;
+ for(i = 0; i < arr.length; i++) sum += arr[i];
+ return sum;
+ }
View
72 speed/index.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <title>Speed Test</title>
+ <script src="jquery-basis.js" type="text/javascript"></script>
+ <script src="../dist/jquery.js" type="text/javascript"></script>
+ <script type="text/javascript">jQuery.noConflict();</script>
+ <link rel="stylesheet" href="benchmarker.css" type="text/css" media="screen" />
+</head>
+
+<body>
+
+<h1>Speed Test</h1>
+<div id="badid"></div>
+<div id="time-test">
+<p>Using the following selector expressions (<input type="text" id="times" maxlength="5" size="5" value="20"/> times each):</p>
+<p>NOTE: Number shown is an average.</p>
+<div class="buttons">
+ <button class="selectAll">Select All</button>
+ <button class="deselectAll">Deselect All</button>
+
+ <button class="runTests">Run Tests</button>
+ <button class="retryTies">Retry Ties</button>
+</div>
+<table cellspacing="0">
+ <thead>
+ <tr>
+ <th>Run?</th>
+ <th>Test</th>
+
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <th></th>
+ <th></th>
+ </tr>
+ <tr>
+ <th></th>
+
+ <th></th>
+ </tr>
+ </tfoot>
+ <tbody>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ </tbody>
+
+</table>
+
+ <div class="buttons">
+ <button class="selectAll">Select All</button>
+ <button class="deselectAll">Deselect All</button>
+ <button class="runTests">Run Tests</button>
+ <button class="retryTies">Retry Ties</button>
+ <button id="addTest">+</button>
+
+ </div>
+</div>
+<div style="display:none;"><div id="page"><div id="masthead"><div id="mastheadhd"></div><div id="mastheadbd"><div class="mastheadbd"><div id="eyebrow"><ul id="ypromo"><li><a id="sethomepage" href=""><strong>Make Y! your home page</strong></a></li><li id="toolbar"><a id="dtba" href=""><span id="tba">Get</span> Yahoo! Toolbar</a></li></ul><div id="ffhpcx"></div><div id="headline"><span><a href="">How much home can you afford?</a></span></div></div><h1><img src="blank.gif" border=0 width=232 height=44 alt="Yahoo!" id="ylogo"></h1><div id="searchwrapper"><form name="sf1" id="search" action="r/sx/*-http://search.yahoo.com/search"><fieldset><legend>Yahoo! Search</legend><ul id="vsearchtabs"><li class="first on"><a href="">Web</a></li><li><a href="">Images</a></li><li><a href="">Video</a></li><li><a href="">Local</a></li><li><a href="">Shopping</a></li><li class="last ignore"><dl id="vsearchm"><dt><a id="vsearchmore" href="">More</a></dt><dd id="vslist"></dd></dl></li></ul><div id="sbox"><label id="searchlabel" for="p">Search:</label><div class="outer_search_container"><div id="search_container" class="search_container"><img src="blank.gif" id="searchother_e2e" alt=""><div id="searchIE"><div id="searchmw1" class="iemw"></div></div><div class="fixfloat searchbox_container"><div id="searchbox"><input class="plong inputtext" type="text" id="p" name="p" accesskey="s"></div><span id="searchbtn"><input type="submit" id="searchsubmit" class="btn-more-2" value="Web Search"></span></div></div><div id="e2eClass" class="e2e"><div class="e2eTween"></div><div id="e2e"><div id="e2econtent"><div id="e2e_intl"></div><div class="ac_container"><div id="e2einfo"></div><div id="ac_container"></div><div id="e2escroll"></div></div></div><a title="toggle search suggestions" id="e2etoggle" href="" onclick="return false;"><img src="blank.gif" id="searchtoggle_e2e" alt="toggle search suggestions"></a></div></div></div><input type="hidden" name="fr" value="yfp"><input type="hidden" name="toggle" value="1"><input type="hidden" name="cop" value="mss"><input type="hidden" name="ei" value="UTF-8"></div><div id="sboxfooter"></div></fieldset></form></div><div class="mh_footer"><div id="doors"><h3 class="a11y">Popular Yahoo! Properties</h3><ul id="doors-links" class="fixfloat"><li class="first"><strong>Yahoo! Home</strong></li><li class="middle"><a href=r/i1 title="Go to My Yahoo!">My Yahoo!</a></li><li class="last"></li></ul></div><div id="pagesettingscx"><span id="navbardate"><cite class="timestamp">&nbsp;</cite></span><a href="" id="editpage">Page Options</a><div id="pagesettings"><div class="bd"><span><div class="iemw"></div><div id="pscolors"><h4>Color:</h4><ol id="themes"><li><a href="" id="t1" class="on" title="Ocean">Ocean</a></li><li><a href="" id="t4" title="Tangerine">Tangerine</a></li><li><a href="" id="t3" title="Violet">Violet</a></li><li><a href="" id="t2" title="Oyster">Oyster</a></li><li><a href="" id="t5" title="Grass">Grass</a></li><li><a href="" id="t7" title="Pink">Pink</a></li></ol></div><a id="sizetogglelink" href="">Switch to narrow layout</a><a id="myyahoolink" href="">Want more ways to customize <span>your home page?</span><span class="trymyyahoo">Try My Yahoo! &#187;</span></a></span></div></div></div></div></div></div><div id="mastheadft"></div></div><div id="colcx"><div id="left"><div id="trough" class="md"><div class="bd"><div id="trough-cols" class="fixfloat"><ul id="trough-1" class="col1"><li><a style="background-position:-400px -120px" href="">Answers</a></li><li><a style="background-position:-400px -440px" href="">Autos</a></li><li><a style="background-position:0 -761px" href="">Finance</a></li><li><a style="background-position:0 -1600px" href="">Games</a></li><li><a style="background-position:0 -1400px" href="">Groups</a></li><li><a style="background-position:0 -439px" href="">HotJobs</a></li><li><a style="background-position:0 -600px" href="">Maps</a></li><li><a style="background-position:0 -161px" href="">Mobile Web</a></li><li><a style="background-position:0 -561px;display:inline" href="">Movies</a> | <a class="trough_tv" href="">TV</a></li><li><a style="background-position:0 -1562px" href="">Music</a></li><li><a style="background-position:-400px -1119px" href="">OMG</a></li><li class="highlight"><a style="background-position:0 -40px" href="">Personals</a></li><li><a style="background-position:-400px -161px" href="">Real Estate<small class="updated"></small></a></li><li><a style="background-position:-400px -1321px" href="">Shine</a></li><li><a style="background-position:0 -1640px" href="">Shopping</a></li><li><a style="background-position:0 -800px" href="">Sports</a></li><li><a style="background-position:0 -79px" href="">Travel</a></li><li><a style="background-position:0 -121px" href="">Yellow Pages</a></li></ul></div><span id="allyservicescx"><a href="" id="allyservices" class="btn-more-2" title="View the complete list of Yahoo! Services">More Yahoo! Services</a></span></div></div><div class="md minimantle"><div id="smallbiz" class="md-sub"><div class="hd"><h2><a href="">Small Business</a></h2></div><ul id="smallbiz-links"><li><a href="">Get a Web Site</a></li><li><a href="">Domain Names</a></li><li><a href="">Sell Online</a></li><li><a href="">Search Ads</a></li></ul></div></div><div class="md minimantle"><div id="advertising" class="md-sub"><div class="hd"><h2><a href="">Featured Services</a></h2></div><ul id="advertising-links"><li><a href="">Downloads</a></li><li><a href="">Health</a></li><li><a href="">Kids</a></li><li><a href="">GeoCities</a></li><li><a href="">Mail Plus</a></li><li><a href="">Y! International</a></li></ul></div></div></div><div id="rightcx"><div id="middle"><div class="colpadding"><div id="today" class="md featured1"><div class="hd tabs"><h3 class="a11y">Featured Navigation</h3><ul id="todaytabs"><li class="on first"><em><a hidefocus="true" id="featured1" href="">Featured</a></em><span class="pipe"></span></li><li class="tab2"><em><a hidefocus="true" id="entertainment1" href="">Entertainment</a></em><span class="pipe"></span></li><li class="tab3"><em><a hidefocus="true" id="sports1" href="">Sports</a></em><span class="pipe"></span></li><li class="last"><em><a hidefocus="true" id="money1" href="">Video</a></em><span class="pipe"></span></li></ul></div><div id="todayvideo"></div><div id="todaybd" class="bd"><cite class="timestamp">&nbsp;</cite><span id="featured1ct" class="current"><div id="featured1main"><a href=s/1014544><img src="blank.gif" width="154" height="115" alt="Renee Zellweger (Steve Grantiz/WireImage)"></a><span><h3><a href=s/1014544>Worst dressed at the Globes</a></h3><p>Renee's look is a mess, and Miley's gown is a mistake. <a class=more href=s/1014544>&#187; See bad outfits</a></p><ul><li><a class=slideshow href=s/1014545>Best dressed</a></li><li><a class=slideshow href=s/1014546>Stunning couples</a></li><li><a class=video href=s/1014547>Watch Brangelina diss Ryan Seacrest</a></li><li><a class=bullet href=s/1014548>Outrageous moments</a></li><li><a class=bullet href=s/1014549>Big winners</a></li></ul></span></div></span><span id="featured2ct"></span><span id="featured3ct"></span><span id="featured4ct"></span><span id="entertainment1ct"></span><span id="entertainment2ct"></span><span id="entertainment3ct"></span><span id="entertainment4ct"></span><span id="sports1ct"></span><span id="sports2ct"></span><span id="sports3ct"></span><span id="sports4ct"></span><span id="money1ct"></span><span id="money2ct"></span><span id="money3ct"></span><span id="money4ct"></span></div><div id="todayft" class="ft"><span id="footer1" class="current"><ul id="todaystories1"><li id="featured1|106537" class="on"><a href=s/1014556><img src="blank.gif" alt="" width="29" height="21">See the worst-dressed stars at Golden Globes</a></li><li id="featured2|106533"><a href=s/1014475><img src="blank.gif" alt="" width="29" height="21">Obama: Dog search down to two breeds</a></li><li id="featured3|106522"><a href=s/1014275><img src="blank.gif" alt="" width="29" height="21">Eagles star gets penalty for 'phone call'</a></li><li id="featured4|106538"><a href=s/1014566><img src="blank.gif" alt="" width="29" height="21">Teen sends 14,528 texts in one month</a></li></ul><div id="more-featured" class="btn-more"><b>&#187;</b> More:<a class="first" href="">Featured</a><a class="last" href="">Buzz</a></div></span><span id="footer2"></span><span id="footer3"></span><span id="footer4"></span></div></div><div id="adwest" class="ad"></div><div id="news" class="md"><div class="hd tabs"><h3 class="a11y">News Navigation</h3><ul id="newstabs"><li class="on first"><em><a hidefocus="true" id="inthenews2" href="">News</a></em><span class="pipe"></span></li><li class="tab2"><em><a hidefocus="true" id="worldnews" href="">World</a></em><span class="pipe"></span></li><li class="tab3"><em><a hidefocus="true" id="localnews" href="">Local</a></em><span class="pipe"></span></li><li class="last"><em><a hidefocus="true" id="finsnews" href="">Finance</a></em><span class="pipe"></span></li></ul></div><div id="newsbd" class="bd"><span id="inthenews2ct" class="current"><h2 class="a11y">In the News</h2><div id="newstop"><cite class="timestamp">&nbsp;</cite>&#149;&nbsp;<a href=s/1014558>Obama advises Bush to request remaining $350B of bailout</a><br>&#149;&nbsp;<a href=s/1014502>Bush defends his presidency in final news conference</a><br>&#149;&nbsp;<a href=s/1014534>More than 900 Gazans dead as Israel continues attacks</a><br>&#149;&nbsp;<a href=s/1014517>Openly gay Episcopal bishop to say prayer at inaugural event</a><br>&#149;&nbsp;<a href=s/1014567>NYC judge allows Bernard Madoff to remain free on bail</a><br>&#149;&nbsp;<a href=s/1014516>British PM backing Prince Harry after racist remark</a><br>&#149;&nbsp;<a class=video style="background-position:-3px -48px;font:normal 100% arial;" href=s/1014537 onclick="window.open('s/1014537','playerWindow','width=793,height=608,scrollbars=no');return false;">Brothers separated at birth reunite after 80 years</a><br><ul id="more-news" class="btn-more"><li class="first"><b>&#187;</b> More:</li><li><a href=r/xn>News</a></li><li><a href=r/me>Popular</a></li><li class="last"><a href=r/z0>Politics</a></li></ul></div><div id="newsft"><div id="newsbottom"><div id="finance-data"><div id="markets"><h3><a href="">Markets:</a></h3><ul><li><strong><a href="">Dow: </a><span class="down">-1.0%</span></strong></li><li><strong><a href="">Nasdaq: </a><span class="down">-1.7%</span></strong></li></ul></div><div id="quotes"><form name="fq" id="fq" action="r/f4/*-http://finance.yahoo.com/q"><fieldset><legend>Yahoo! Finance</legend> <a href="">Real-Time Quotes:</a><input accesskey="q" class="inputtext" type="text" id="s" name="s" size="5" title="Enter ticker symbol" /><input type="submit" class="submit" value="Go" /></fieldset></form></div></div><div id="news-sponsor"><a href=""><img src="blank.gif" border=0 width=165 height=15 title="Switch to Scottrade"></a></div></div></div></span><span id="worldnewsct"></span><span id="localnewsct"></span><span id="finsnewsct"></span></div></div><div id="marketplace" class="md"><div class="hd"><h2><a href="" name="marketplace">Marketplace</a></h2></div><div id="marketplacebd" class="bd"><table border=0 cellpadding=0 cellspacing=0 width="100%"><tr><td valign=top><a href=""><img src="blank.gif" width=70 height=50 border=0></a></td><td width=8>&nbsp;</td><td valign=top><font face=arial size=-1><a href="">Why online college is rocking:</a><br>1) Accredited Associates, Bachelor&#39;s, Master&#39;s, MBA degrees 2) Some jobs pay tuition <a href="">3) Top schools online.</a></font></td></tr></table><hr size=1 noshade><a href="">A bad credit score is 600 or below. Click here to see yours online in just 2 easy steps for $0. By Experian&reg;</a><hr size=1 noshade><a href="">GEICO Car Insurance -</a> You could save over $500 on car insurance. <a href="">Get a fast, free quote.</a><hr size=1 noshade><a href="">100+ credit cards from 9 of the top 10 issuers. Instant approvals. Choose the right card for you. LendingTree&reg;</a></div></div></div></div><div id="right"><div class="colpadding"><div id="pa" class="md"><div id="pabd"><div id="patop"><ul id="reg" class="so"><li class="mailstatus">Check your mail status: <a href="">Sign In</a></li><li id="signup">Free mail: <a href="">Sign Up</a></li></ul></div><div id="patabs"><ul id="tabs1" class="patabs first"><li id="mail" class="first"><div><h4><a id="pamail" accesskey="m" href=""><span class="icon">Mail</span></a></h4></div></li><li id="messenger"><div><h4><a id="pamsgr" href=""><span class="icon">Messenger</span></a></h4></div></li><li id="games" class="last"><div><h4><a id="pagames" href=""><span class="icon">Puzzles</span></a></h4></div></li></ul><div id="tabs1previewdiv" class="papreviewdiv"></div><ul id="tabs2" class="patabs last"><li id="weather" class="first"><div><h4><a id="paweather" href=""><span class="icon">Weather</span></a></h4></div></li><li id="events"><div><h4><a id="paevents" href=""><span class="icon">Events</span></a></h4></div></li><li id="horoscope" class="last"><div><h4><a id="pahoroscope" href=""><span class="icon">Horoscopes</span></a></h4></div></li></ul><div id="tabs2previewdiv" class="papreviewdiv"></div></div></div></div><div id="ad" class="ad"><table cellspacing=0 cellpadding=0 border=0 width=100%><tr><td align=center><a href="" target="_top"><img src="blank.gif" alt="" width=300 height=250 border=0></a></td></tr><tr><td align=center><br><font face="verdana" size="-2"><a href="" target="_blank">Ad Feedback</a></font></td></tr></table></div><div id="mantlecx"><div id="mantle"><div id="mantle2" class="md"><div class="hd"><h2><a href="">Inside Yahoo! HotJobs</a></h2> </div><div class="bd"><a href=""><img src="blank.gif" height="68" width="92" alt="Yahoo! HotJobs" border="0"></a><h3><a href="">Great companies hiring now</a></h3><ul><li><a href="">Careers with bright futures</a></li><li><a href="">Low-stress jobs that pay</a></li><li><a href="">Super-easy career changes</a></li><li><a href="">How to find a job right for you</a></li></ul></div></div></div></div><div id="pulse" class="md"><div class="hd"><h2>Pulse - What Yahoos Are Into</h2></div><div id="pulsebd" class="bd"><h3>Star Searches: Most Popular Actors</h3><a href=s/1013525/*-http://movies.yahoo.com/movie/contributor/1800043966><img src="blank.gif" alt="Alyssa Milano (Steve Granitz, WireImage.com)" width="139" height="119"></a><ol><li class="tt1"><a href=s/1013525/*-http://movies.yahoo.com/movie/contributor/1800043966>Alyssa Milano</a></li><li class="tt2"><a href=s/1013526/*-http://movies.yahoo.com/movie/contributor/1800018965>Brad Pitt</a></li><li class="tt3"><a href=s/1013527/*-http://movies.yahoo.com/movie/contributor/1804705919>Anne Hathaway</a></li><li class="tt4"><a href=s/1013528/*-http://movies.yahoo.com/movie/contributor/1800424122>Ziyi Zhang</a></li><li class="tt5"><a href=s/1013529/*-http://movies.yahoo.com/movie/contributor/1800019484>Charlize Theron</a></li><li class="tt6"><a href=s/1013530/*-http://movies.yahoo.com/movie/contributor/1800019485>Johnny Depp</a></li></ol></div><a class=btn-more href=s/1013531/*-http://movies.yahoo.com>&#187; More Yahoo! Movies</a></div><div id="popsearch" class="md"><div class="hd"><h2>Today&#039;s Top Searches</h2></div><div id="popsearchbd" class="bd"><ol start=1><li><a href="">Odette Yustman</a></li><li><a href="">Kate Hudson</a></li><li><a href="">Ana Ortiz</a></li><li><a href="">Weight Loss Tips</a></li><li><a href="">Kimberley Locke</a></li></ol><ol start=6><li><a href="">Rod Blagojevich</a></li><li><a href="">2009 Jeep Commander</a></li><li><a href="">Attention Deficit...</a></li><li><a href="">Snoring</a></li><li><a href="">New Orleans Vacations</a></li></ol></div></div></div></div></div></div><div id="footer" class="md"><ul id="flist2"><li class="first"><a href="">Advertise with Us</a></li><li><a href="">Search Marketing</a></li><li><a href="">Privacy Policy</a></li><li><a href="">Terms of Service</a></li><li><a href=r/ad>Suggest a Site</a></li><li><a href="">Yahoo! en Espa&ntilde;ol</a></li><li><a href="">Send Feedback</a></li><li class="last"><a href="">Help</a></li></ul><ul id="copyright"><li class="first">Copyright &copy; 2009 Yahoo! Inc. All rights reserved.</li><li class="first"><a href="">Copyright/IP Policy</a></li><li><a href="">Company Info</a></li><li><a href="">Participate in Research</a></li><li><a href="">Jobs</a></li></ul></div></div> <div id="yblthm_sip" style="display:none"></div></div>
+ <script type="text/javascript" charset="utf-8">
+ jQuery.benchmarker = {libraries: ["$", "jQuery"]};
+ </script>
+
+ <script type="text/javascript" src="benchmarker.js"></script>
+</body>
+</html>
View
3,549 speed/jquery-basis.js
3,549 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
179 src/attributes.js
@@ -1,55 +1,40 @@
-// exclude the following css properties to add px
-var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
- // cache defaultView
- defaultView = document.defaultView || {};
-
jQuery.fn.extend({
- attr: function( name, value, type ) {
+ attr: function( name, value ) {
var options = name, isFunction = jQuery.isFunction( value );
- // Look for the case where we're accessing a style value
if ( typeof name === "string" ) {
+ // Are we setting the attribute?
if ( value === undefined ) {
return this.length ?
- jQuery[ type || "attr" ]( this[0], name ) :
+ jQuery.attr( this[0], name ) :
null;
+ // Convert name, value params to options hash format
} else {
options = {};
options[ name ] = value;
}
}
- // Check to see if we're setting style values
+ // For each element...
for ( var i = 0, l = this.length; i < l; i++ ) {
var elem = this[i];
- // Set all the styles
+ // Set all the attributes
for ( var prop in options ) {
value = options[prop];
if ( isFunction ) {
value = value.call( elem, i );
}
- if ( typeof value === "number" && type === "curCSS" && !exclude.test(prop) ) {
- value = value + "px";
- }
-
- jQuery.attr( type ? elem.style : elem, prop, value );
+ jQuery.attr( elem, prop, value );
}
}
return this;
},
- css: function( key, value ) {
- // ignore negative width and height values
- if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
- value = undefined;
- return this.attr( key, value, "curCSS" );
- },
-
hasClass: function( selector ) {
return !!selector && this.is( "." + selector );
},
@@ -181,119 +166,6 @@ jQuery.extend({
}
},
- // A method for quickly swapping in/out CSS properties to get correct calculations
- swap: function( elem, options, callback ) {
- var old = {};
- // Remember the old values, and insert the new ones
- for ( var name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
-
- callback.call( elem );
-
- // Revert the old values
- for ( var name in options )
- elem.style[ name ] = old[ name ];
- },
-
- css: function( elem, name, force, extra ) {
- if ( name == "width" || name == "height" ) {
- var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
-
- function getWH() {
- val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
-
- if ( extra === "border" )
- return;
-
- jQuery.each( which, function() {
- if ( !extra )
- val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
- if ( extra === "margin" )
- val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
- else
- val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
- });
- }
-
- if ( elem.offsetWidth !== 0 )
- getWH();
- else
- jQuery.swap( elem, props, getWH );
-
- return Math.max(0, Math.round(val));
- }
-
- return jQuery.curCSS( elem, name, force );
- },
-
- curCSS: function( elem, name, force ) {
- var ret, style = elem.style;
-
- // We need to handle opacity special in IE
- if ( name == "opacity" && !jQuery.support.opacity ) {
- ret = jQuery.attr( style, "opacity" );
-
- return ret == "" ?
- "1" :
- ret;
- }
-
- // Make sure we're using the right name for getting the float value
- if ( name.match( /float/i ) )
- name = styleFloat;
-
- if ( !force && style && style[ name ] )
- ret = style[ name ];
-
- else if ( defaultView.getComputedStyle ) {
-
- // Only "float" is needed here
- if ( name.match( /float/i ) )
- name = "float";
-
- name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
-
- var computedStyle = defaultView.getComputedStyle( elem, null );
-
- if ( computedStyle )
- ret = computedStyle.getPropertyValue( name );
-
- // We should always get a number back from opacity
- if ( name == "opacity" && ret == "" )
- ret = "1";
-
- } else if ( elem.currentStyle ) {
- var camelCase = name.replace(/\-(\w)/g, function(all, letter){
- return letter.toUpperCase();
- });
-
- ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
-
- // From the awesome hack by Dean Edwards
- // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
-
- // If we're not dealing with a regular pixel number
- // but a number that has a weird ending, we need to convert it to pixels
- if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
- // Remember the original values
- var left = style.left, rsLeft = elem.runtimeStyle.left;
-
- // Put in the new values to get a computed value out
- elem.runtimeStyle.left = elem.currentStyle.left;
- style.left = ret || 0;
- ret = style.pixelLeft + "px";
-
- // Revert the changed values
- style.left = left;
- elem.runtimeStyle.left = rsLeft;
- }
- }
-
- return ret;
- },
-
attr: function( elem, name, value ) {
// don't set attributes on text and comment nodes
if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
@@ -307,7 +179,6 @@ jQuery.extend({
name = notxml && jQuery.props[ name ] || name;
// Only do all the following if this is a node (faster for style)
- // IE elem.getAttribute passes even for style
if ( elem.tagName ) {
// These attributes require special treatment
@@ -348,8 +219,12 @@ jQuery.extend({
return elem[ name ];
}
- if ( !jQuery.support.style && notxml && name == "style" )
- return jQuery.attr( elem.style, "cssText", value );
+ if ( !jQuery.support.style && notxml && name == "style" ) {
+ if ( set )
+ elem.style.cssText = "" + value;
+
+ return elem.style.cssText;
+ }
if ( set )
// convert the value to a string (all browsers do this but IE) see #1070
@@ -365,31 +240,7 @@ jQuery.extend({
}
// elem is actually elem.style ... set the style
-
- // IE uses filters for opacity
- if ( !jQuery.support.opacity && name == "opacity" ) {
- if ( set ) {
- // IE has trouble with opacity if it does not have layout
- // Force it by setting the zoom level
- elem.zoom = 1;
-
- // Set the alpha filter to set the opacity
- elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
- (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
- }
-
- return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
- (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
- "";
- }
-
- name = name.replace(/-([a-z])/ig, function(all, letter){
- return letter.toUpperCase();
- });
-
- if ( set )
- elem[ name ] = value;
-
- return elem[ name ];
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style(elem, name, value);
}
});
View
205 src/css.js
@@ -0,0 +1,205 @@
+// exclude the following css properties to add px
+var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ // cache defaultView
+ defaultView = document.defaultView || {},
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
+
+jQuery.fn.css = function( name, value ) {
+ var options = name, isFunction = jQuery.isFunction( value );
+
+ // ignore negative width and height values
+ if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 )
+ value = undefined;
+
+ if ( typeof name === "string" ) {
+ // Are we setting the style?
+ if ( value === undefined ) {
+ return this.length ?
+ jQuery.css( this[0], name ) :
+ null;
+
+ // Convert name, value params to options hash format
+ } else {
+ options = {};
+ options[ name ] = value;
+ }
+ }
+
+ // For each element...
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ // Set all the styles
+ for ( var prop in options ) {
+ value = options[prop];
+
+ if ( isFunction ) {
+ value = value.call( elem, i );
+ }
+
+ if ( typeof value === "number" && !exclude.test(prop) ) {
+ value = value + "px";
+ }
+
+ jQuery.style( elem, prop, value );
+ }
+ }
+
+ return this;
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
+ return undefined;
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name == "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ style.filter = (style.filter || "").replace( /alpha\([^)]*\)/, "" ) +
+ (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( /float/i.test( name ) )
+ name = styleFloat;
+
+ name = name.replace(/-([a-z])/ig, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ if ( set )
+ style[ name ] = value;
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name == "width" || name == "height" ) {
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
+
+ function getWH() {
+ val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" )
+ return;
+
+ jQuery.each( which, function() {
+ if ( !extra )
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ if ( extra === "margin" )
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ else
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 )
+ getWH();
+ else
+ jQuery.swap( elem, props, getWH );
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name == "opacity" ) {
+ ret = style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( /float/i.test( name ) )
+ name = styleFloat;
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( defaultView.getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( /float/i.test( name ) )
+ name = "float";
+
+ name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle )
+ ret = computedStyle.getPropertyValue( name );
+
+ // We should always get a number back from opacity
+ if ( name == "opacity" && ret == "" )
+ ret = "1";
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(/\-(\w)/g, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = ret || 0;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options )
+ elem.style[ name ] = old[ name ];
+ }
+});
View
8 src/fx.js
@@ -305,7 +305,7 @@ jQuery.fx.prototype = {
// Simple 'show' function
show: function(){
// Remember where we started, so that we can go back to it later
- this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
this.options.show = true;
// Begin the animation
@@ -320,7 +320,7 @@ jQuery.fx.prototype = {
// Simple 'hide' function
hide: function(){
// Remember where we started, so that we can go back to it later
- this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
this.options.hide = true;
// Begin the animation
@@ -361,7 +361,7 @@ jQuery.fx.prototype = {
// Reset the properties, if the item has been hidden or shown
if ( this.options.hide || this.options.show )
for ( var p in this.options.curAnim )
- jQuery.attr(this.elem.style, p, this.options.orig[p]);
+ jQuery.style(this.elem, p, this.options.orig[p]);
// Execute the complete function
this.options.complete.call( this.elem );
@@ -395,7 +395,7 @@ jQuery.extend( jQuery.fx, {
step: {
opacity: function(fx){
- jQuery.attr(fx.elem.style, "opacity", fx.now);
+ jQuery.style(fx.elem, "opacity", fx.now);
},
_default: function(fx){
View
5 src/support.js
@@ -91,14 +91,9 @@
});
})();
-var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
-
jQuery.props = {
"for": "htmlFor",
"class": "className",
- "float": styleFloat,
- cssFloat: styleFloat,
- styleFloat: styleFloat,
readonly: "readOnly",
maxlength: "maxLength",
cellspacing: "cellSpacing",
View
1 test/index.html
@@ -17,6 +17,7 @@
<script type="text/javascript" src="unit/core.js"></script>
<script type="text/javascript" src="unit/data.js"></script>
<script type="text/javascript" src="unit/attributes.js"></script>
+ <script type="text/javascript" src="unit/css.js"></script>
<script type="text/javascript" src="unit/traversing.js"></script>
<script type="text/javascript" src="unit/manipulation.js"></script>
<script type="text/javascript" src="unit/dimensions.js"></script>
View
83 test/unit/attributes.js
@@ -232,89 +232,6 @@ test("attr('tabindex', value)", function() {
equals(element.attr('tabindex'), -1, 'set negative tabindex');
});
-test("css(String|Hash)", function() {
- expect(19);
-
- equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');
-
- ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
- jQuery('#nothiddendiv').css({display: 'none'});
- ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
- jQuery('#nothiddendiv').css({display: 'block'});
- ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
-
- jQuery('#floatTest').css({styleFloat: 'right'});
- equals( jQuery('#floatTest').css('styleFloat'), 'right', 'Modified CSS float using "styleFloat": Assert float is right');
- jQuery('#floatTest').css({cssFloat: 'left'});
- equals( jQuery('#floatTest').css('cssFloat'), 'left', 'Modified CSS float using "cssFloat": Assert float is left');
- jQuery('#floatTest').css({'float': 'right'});
- equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');
- jQuery('#floatTest').css({'font-size': '30px'});
- equals( jQuery('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');
-
- jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
- jQuery('#foo').css({opacity: n});
- equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
- jQuery('#foo').css({opacity: parseFloat(n)});
- equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
- });
- jQuery('#foo').css({opacity: ''});
- equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
-});
-
-test("css(String, Object)", function() {
- expect(21);
- ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
- jQuery('#nothiddendiv').css("display", 'none');
- ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
- jQuery('#nothiddendiv').css("display", 'block');
- ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
-
- jQuery('#floatTest').css('styleFloat', 'left');
- equals( jQuery('#floatTest').css('styleFloat'), 'left', 'Modified CSS float using "styleFloat": Assert float is left');
- jQuery('#floatTest').css('cssFloat', 'right');
- equals( jQuery('#floatTest').css('cssFloat'), 'right', 'Modified CSS float using "cssFloat": Assert float is right');
- jQuery('#floatTest').css('float', 'left');
- equals( jQuery('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');
- jQuery('#floatTest').css('font-size', '20px');
- equals( jQuery('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');
-
- jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
- jQuery('#foo').css('opacity', n);
- equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
- jQuery('#foo').css('opacity', parseFloat(n));
- equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
- });
- jQuery('#foo').css('opacity', '');
- equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
- // for #1438, IE throws JS error when filter exists but doesn't have opacity in it
- if (jQuery.browser.msie) {
- jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
- }
- equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );
-
- // using contents will get comments regular, text, and comment nodes
- var j = jQuery("#nonnodes").contents();
- j.css("padding-left", "1px");
- equals( j.css("padding-left"), "1px", "Check node,textnode,comment css works" );
-
- // opera sometimes doesn't update 'display' correctly, see #2037
- jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML
- equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
-});
-
-test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {
- expect(4);
-
- var $checkedtest = jQuery("#checkedtest");
- // IE6 was clearing "checked" in jQuery.css(elem, "height");
- jQuery.css($checkedtest[0], "height");
- ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
- ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
- ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
- ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
-});
-
test("width()", function() {
expect(6);
View
82 test/unit/css.js
@@ -0,0 +1,82 @@
+test("css(String|Hash)", function() {
+ expect(19);
+
+ equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');
+
+ ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
+ jQuery('#nothiddendiv').css({display: 'none'});
+ ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
+ jQuery('#nothiddendiv').css({display: 'block'});
+ ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
+
+ jQuery('#floatTest').css({styleFloat: 'right'});
+ equals( jQuery('#floatTest').css('styleFloat'), 'right', 'Modified CSS float using "styleFloat": Assert float is right');
+ jQuery('#floatTest').css({cssFloat: 'left'});
+ equals( jQuery('#floatTest').css('cssFloat'), 'left', 'Modified CSS float using "cssFloat": Assert float is left');
+ jQuery('#floatTest').css({'float': 'right'});
+ equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');
+ jQuery('#floatTest').css({'font-size': '30px'});
+ equals( jQuery('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');
+
+ jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
+ jQuery('#foo').css({opacity: n});
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
+ jQuery('#foo').css({opacity: parseFloat(n)});
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
+ });
+ jQuery('#foo').css({opacity: ''});
+ equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
+});
+
+test("css(String, Object)", function() {
+ expect(21);
+ ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
+ jQuery('#nothiddendiv').css("display", 'none');
+ ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
+ jQuery('#nothiddendiv').css("display", 'block');
+ ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
+
+ jQuery('#floatTest').css('styleFloat', 'left');
+ equals( jQuery('#floatTest').css('styleFloat'), 'left', 'Modified CSS float using "styleFloat": Assert float is left');
+ jQuery('#floatTest').css('cssFloat', 'right');
+ equals( jQuery('#floatTest').css('cssFloat'), 'right', 'Modified CSS float using "cssFloat": Assert float is right');
+ jQuery('#floatTest').css('float', 'left');
+ equals( jQuery('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');
+ jQuery('#floatTest').css('font-size', '20px');
+ equals( jQuery('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');
+
+ jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
+ jQuery('#foo').css('opacity', n);
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
+ jQuery('#foo').css('opacity', parseFloat(n));
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
+ });
+ jQuery('#foo').css('opacity', '');
+ equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
+ // for #1438, IE throws JS error when filter exists but doesn't have opacity in it
+ if (jQuery.browser.msie) {
+ jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
+ }
+ equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = jQuery("#nonnodes").contents();
+ j.css("padding-left", "1px");
+ equals( j.css("padding-left"), "1px", "Check node,textnode,comment css works" );
+
+ // opera sometimes doesn't update 'display' correctly, see #2037
+ jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML
+ equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
+});
+
+test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {
+ expect(4);
+
+ var $checkedtest = jQuery("#checkedtest");
+ // IE6 was clearing "checked" in jQuery.css(elem, "height");
+ jQuery.css($checkedtest[0], "height");
+ ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
+ ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
+ ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
+ ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
+});
View
2 test/unit/fx.js
@@ -365,7 +365,7 @@ jQuery.each( {
if ( t_h == "hide"||t_h == "show" )
equals(this.style.height.indexOf(f_h), 0, "Height must be reset to " + f_h + ": " + this.style.height);
- var cur_o = jQuery.attr(this.style, "opacity");
+ var cur_o = jQuery.style(this, "opacity");
if ( cur_o !== "" ) cur_o = parseFloat( cur_o );
if ( t_o == "hide"||t_o == "show" )

0 comments on commit d7d908b

Please sign in to comment.