Compare commits
197 Commits
Author | SHA1 | Date |
---|---|---|
Denis Knauf | bb7d98f018 | |
jaubourg | e6f8951983 | |
jaubourg | e83fcdcb02 | |
jaubourg | 139135a98a | |
jaubourg | 5b92a5f5ec | |
John Resig | e2ab2ba1d5 | |
John Resig | aa6f8c8cd3 | |
timmywil | ab1504f14f | |
timmywil | 96501d38a9 | |
Mike Sherov | 124817e668 | |
John Resig | d59b0f3e27 | |
John Resig | d269e426e0 | |
John Resig | 138d5b7b81 | |
John Resig | d443e533aa | |
Schalk Neethling | 8a532d1575 | |
rwldrn | 5eef5917fd | |
Greg Hazel | 13ceb0f56b | |
rwldrn | 6926247bf4 | |
timmywil | 641ad80211 | |
timmywil | 39a2f29c29 | |
timmywil | db437be6e3 | |
timmywil | 0a80be67f4 | |
timmywil | d66c3b6d84 | |
rwldrn | 6490c10c75 | |
timmywil | 75203de743 | |
Mike Sherov | 80ad14bd14 | |
rwldrn | 0742056645 | |
rwldrn | c3c001cf5b | |
timmywil | 71d2e657d0 | |
timmywil | 1d202c6afc | |
timmywil | 9d4033d629 | |
timmywil | bdce86dc2e | |
timmywil | edb2286544 | |
timmywil | 1d1cb582c0 | |
Scott Hughes | 287156197f | |
rwldrn | 408c98fb4b | |
timmywil | b8fc9d14a1 | |
timmywil | 657b197c19 | |
timmywil | a5396bde70 | |
timmywil | e5457a5a1f | |
Mathias Bynens | b43910a496 | |
rwldrn | f82b9dddc4 | |
timmywil | a1545b5079 | |
timmywil | 25118e22a2 | |
timmywil | ba90af0dc5 | |
timmywil | 7d3ba9f89e | |
Rick Waldron | c17f589ec9 | |
timmywil | a5cf257a8a | |
timmywil | 6171e0a923 | |
timmywil | cf702496ee | |
timmywil | bc82ff0ff9 | |
timmywil | 6f676e692d | |
Rick Waldron | ec829431fe | |
timmywil | a5b7c0fa33 | |
avaly | cbbd7d28e1 | |
timmywil | 3486365062 | |
jaubourg | 0f81cf8991 | |
jaubourg | ceba855c01 | |
John Resig | b60c8560ce | |
John Resig | 9fd37b2c8a | |
timmywil | 01c5b7f7f5 | |
John Resig | f794f48f02 | |
jaubourg | 391398cf23 | |
timmywil | 3a1c27b508 | |
John Resig | 68d980bbb4 | |
John Resig | 344af56868 | |
John Resig | f9cccd05b6 | |
John Resig | 2812a87da7 | |
John Resig | c42360b5be | |
John Resig | d2fea6123f | |
John Resig | c8374fafe5 | |
timmywil | d75c61a5bd | |
John Resig | 1ec003f10c | |
John Resig | a5e407cafb | |
John Resig | 419b5e5e2a | |
louisremi | 521ae562da | |
Sahab Yazdani | 304dd618b7 | |
jaubourg | 38de389a8e | |
louisremi | 966c2fe46a | |
timmywil | 4526c8b0a0 | |
louisremi | f34a90b3f7 | |
louisremi | 076c347605 | |
jaubourg | 8c13cfa805 | |
jaubourg | efd0fce7a1 | |
timmywil | 18b1cf2942 | |
timmywil | 90f37aaf7a | |
timmywil | 8bb6e95b66 | |
Daniel Pihlstrom | 3d1c27d52e | |
gnarf | 31268449b9 | |
timmywil | c085563270 | |
timmywil | 09c0cf995b | |
timmywil | c864455ccf | |
timmywil | c72b0f3256 | |
timmywil | f7f8450041 | |
timmywil | a257e07ae4 | |
timmywil | f30cd4155e | |
timmywil | cccf9ad91d | |
timmywil | 5097e6d1c6 | |
timmywil | 5195335cf4 | |
timmywil | 3ed4b22073 | |
timmywil | 480b88ca37 | |
timmywil | 97144424cc | |
John Resig | a9d9f8c542 | |
John Resig | bfad45fe45 | |
John Resig | 3cdffce19f | |
timmywil | 4ac2fdda2c | |
timmywil | 6d2fd57f45 | |
timmywil | ea24cd106b | |
timmywil | 3dbd7b54de | |
John Resig | 89fd9dffad | |
John Resig | f8a112f08e | |
John Resig | f4b5d3fc51 | |
John Resig | c0d993903b | |
John Resig | 53f275034a | |
John Resig | eae7c4111c | |
John Resig | ca338dc749 | |
John Resig | 6c449fd5df | |
John Resig | 86aa764f0b | |
timmywil | f1392d8208 | |
timmywil | 24a8ffb3ea | |
Rick Waldron | 0c2d1aee54 | |
Dave Methvin | e2bace8fa1 | |
Rick Waldron | bf678fd9d6 | |
Rick Waldron | ca367674c1 | |
Dave Methvin | e5f4ec846c | |
MONTILLET Xavier | ebf2faca1e | |
timmywil | b8a9c2ba34 | |
rwldrn | 57f56be04f | |
rwldrn | 632cd6c4ba | |
Rick Waldron | ebac797ac2 | |
timmywil | c0450f3c2a | |
John Resig | b5772da087 | |
John Resig | a8988e3cd1 | |
John Resig | fd11df1ec4 | |
John Resig | 455edf197a | |
Julian Aubourg | 742e15c638 | |
Rick Waldron | 08f52d69bd | |
timmywil | fb65ba418a | |
rwldrn | 86d5d3e809 | |
timmywil | 5165033883 | |
aFarkas | 83e9ce95d7 | |
aFarkas | 9559b1a294 | |
Jordan Boesch | 02ad0aa3b6 | |
timmywil | 15ccae91db | |
John Resig | 9b00827ac9 | |
timmywil | bc7bb0df28 | |
timmywil | 2942be780f | |
Rick Waldron | 3d9445e3fc | |
Dave Methvin | 16312c6b06 | |
timmywil | d274b7b9f7 | |
timmywil | 3ac9eb7ce3 | |
timmywil | dbe966aa57 | |
jaubourg | a28eadff48 | |
jeresig | 60cfab3d19 | |
timmywil | 103d325887 | |
timmywil | 8d2d94cfba | |
timmywil | 825d3d96ce | |
jaubourg | 3a3842c669 | |
Rick Waldron | 8d3754751d | |
timmywil | fb5ef2c4ec | |
timmywil | 34d80709ce | |
John Resig | 15da298f72 | |
John Resig | 2a71493447 | |
Brian Brennan | 3cb9c1835c | |
John Resig | f408aa4314 | |
John Resig | 2786a11053 | |
John Resig | 7a8fac57eb | |
Brian Brennan | d46042e050 | |
timmywil | 230a50ff1c | |
timmywil | 3aa46725ed | |
timmywil | 68cc3ad730 | |
John Resig | 21c0be8496 | |
John Resig | 728a70c036 | |
Gilmore Davidson | a9b81d759a | |
John Resig | adef5c3550 | |
timmywil | ecf6a3c383 | |
Dave Methvin | 235080e125 | |
John Resig | 5d70c6d797 | |
John Resig | 6e3b596514 | |
John Resig | 94ee3e9743 | |
John Resig | 5b197b6c5f | |
John Resig | 8312e2d852 | |
John Resig | ce7b311b92 | |
jaubourg | a519129e99 | |
Sam Bisbee | 4d3cb7d7ee | |
Sam Bisbee | a9a79ccc6e | |
Jordan Boesch | 35d9425969 | |
louisremi | bcc8187b05 | |
Jordan Boesch | c4d0cccecf | |
louisremi | 7bc8227d29 | |
louisremi | 7666c3ef9a | |
louisremi | eccf15be6c | |
timmywil | b6d21592cb | |
jeresig | 8e1467f97e | |
louisremi | 7dc7070426 | |
louisremi | 8806435a77 | |
louisremi | 780b7983d0 |
|
@ -1,4 +1,4 @@
|
|||
[jQuery](http://jquery.com/) - New Wave Javascript
|
||||
[jQuery](http://jquery.com/) - New Wave JavaScript
|
||||
==================================================
|
||||
|
||||
What you need to build your own jQuery
|
||||
|
|
|
@ -182,8 +182,6 @@ var OPERATORS = array_to_hash([
|
|||
">>=",
|
||||
"<<=",
|
||||
">>>=",
|
||||
"~=",
|
||||
"%=",
|
||||
"|=",
|
||||
"^=",
|
||||
"&=",
|
||||
|
@ -191,7 +189,7 @@ var OPERATORS = array_to_hash([
|
|||
"||"
|
||||
]);
|
||||
|
||||
var WHITESPACE_CHARS = array_to_hash(characters(" \n\r\t"));
|
||||
var WHITESPACE_CHARS = array_to_hash(characters(" \n\r\t\u200b"));
|
||||
|
||||
var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:"));
|
||||
|
||||
|
@ -201,20 +199,47 @@ var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy"));
|
|||
|
||||
/* -----[ Tokenizer ]----- */
|
||||
|
||||
function is_alphanumeric_char(ch) {
|
||||
ch = ch.charCodeAt(0);
|
||||
return (ch >= 48 && ch <= 57) ||
|
||||
(ch >= 65 && ch <= 90) ||
|
||||
(ch >= 97 && ch <= 122);
|
||||
// regexps adapted from http://xregexp.com/plugins/#unicode
|
||||
var UNICODE = {
|
||||
letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),
|
||||
non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),
|
||||
space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),
|
||||
connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
|
||||
};
|
||||
|
||||
function is_identifier_char(ch) {
|
||||
return is_alphanumeric_char(ch) || ch == "$" || ch == "_";
|
||||
function is_letter(ch) {
|
||||
return UNICODE.letter.test(ch);
|
||||
};
|
||||
|
||||
function is_digit(ch) {
|
||||
ch = ch.charCodeAt(0);
|
||||
return ch >= 48 && ch <= 57;
|
||||
return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9
|
||||
};
|
||||
|
||||
function is_alphanumeric_char(ch) {
|
||||
return is_digit(ch) || is_letter(ch);
|
||||
};
|
||||
|
||||
function is_unicode_combining_mark(ch) {
|
||||
return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
|
||||
};
|
||||
|
||||
function is_unicode_connector_punctuation(ch) {
|
||||
return UNICODE.connector_punctuation.test(ch);
|
||||
};
|
||||
|
||||
function is_identifier_start(ch) {
|
||||
return ch == "$" || ch == "_" || is_letter(ch);
|
||||
};
|
||||
|
||||
function is_identifier_char(ch) {
|
||||
return is_identifier_start(ch)
|
||||
|| is_unicode_combining_mark(ch)
|
||||
|| is_digit(ch)
|
||||
|| is_unicode_connector_punctuation(ch)
|
||||
|| ch == "\u200c" // zero-width non-joiner <ZWNJ>
|
||||
|| ch == "\u200d" // zero-width joiner <ZWJ> (in my ECMA-262 PDF, this is also 200c)
|
||||
;
|
||||
};
|
||||
|
||||
function parse_js_number(num) {
|
||||
|
@ -253,18 +278,19 @@ function is_token(token, type, val) {
|
|||
|
||||
var EX_EOF = {};
|
||||
|
||||
function tokenizer($TEXT, skip_comments) {
|
||||
function tokenizer($TEXT) {
|
||||
|
||||
var S = {
|
||||
text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
|
||||
pos : 0,
|
||||
tokpos : 0,
|
||||
line : 0,
|
||||
tokline : 0,
|
||||
col : 0,
|
||||
tokcol : 0,
|
||||
newline_before : false,
|
||||
regex_allowed : false
|
||||
text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
|
||||
pos : 0,
|
||||
tokpos : 0,
|
||||
line : 0,
|
||||
tokline : 0,
|
||||
col : 0,
|
||||
tokcol : 0,
|
||||
newline_before : false,
|
||||
regex_allowed : false,
|
||||
comments_before : []
|
||||
};
|
||||
|
||||
function peek() { return S.text.charAt(S.pos); };
|
||||
|
@ -299,7 +325,7 @@ function tokenizer($TEXT, skip_comments) {
|
|||
S.tokpos = S.pos;
|
||||
};
|
||||
|
||||
function token(type, value) {
|
||||
function token(type, value, is_comment) {
|
||||
S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) ||
|
||||
(type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) ||
|
||||
(type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value)));
|
||||
|
@ -311,6 +337,10 @@ function tokenizer($TEXT, skip_comments) {
|
|||
pos : S.tokpos,
|
||||
nlb : S.newline_before
|
||||
};
|
||||
if (!is_comment) {
|
||||
ret.comments_before = S.comments_before;
|
||||
S.comments_before = [];
|
||||
}
|
||||
S.newline_before = false;
|
||||
return ret;
|
||||
};
|
||||
|
@ -351,7 +381,7 @@ function tokenizer($TEXT, skip_comments) {
|
|||
if (ch == "+") return after_e;
|
||||
after_e = false;
|
||||
if (ch == ".") {
|
||||
if (!has_dot)
|
||||
if (!has_dot && !has_x)
|
||||
return has_dot = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -417,7 +447,7 @@ function tokenizer($TEXT, skip_comments) {
|
|||
ret = S.text.substring(S.pos, i);
|
||||
S.pos = i;
|
||||
}
|
||||
return token("comment1", ret);
|
||||
return token("comment1", ret, true);
|
||||
};
|
||||
|
||||
function read_multiline_comment() {
|
||||
|
@ -425,14 +455,41 @@ function tokenizer($TEXT, skip_comments) {
|
|||
return with_eof_error("Unterminated multiline comment", function(){
|
||||
var i = find("*/", true),
|
||||
text = S.text.substring(S.pos, i),
|
||||
tok = token("comment2", text);
|
||||
tok = token("comment2", text, true);
|
||||
S.pos = i + 2;
|
||||
S.line += text.split("\n").length - 1;
|
||||
S.newline_before = text.indexOf("\n") >= 0;
|
||||
|
||||
// https://github.com/mishoo/UglifyJS/issues/#issue/100
|
||||
if (/^@cc_on/i.test(text)) {
|
||||
warn("WARNING: at line " + S.line);
|
||||
warn("*** Found \"conditional comment\": " + text);
|
||||
warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer.");
|
||||
}
|
||||
|
||||
return tok;
|
||||
});
|
||||
};
|
||||
|
||||
function read_name() {
|
||||
var backslash = false, name = "", ch;
|
||||
while ((ch = peek()) != null) {
|
||||
if (!backslash) {
|
||||
if (ch == "\\") backslash = true, next();
|
||||
else if (is_identifier_char(ch)) name += next();
|
||||
else break;
|
||||
}
|
||||
else {
|
||||
if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX");
|
||||
ch = read_escaped_char();
|
||||
if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier");
|
||||
name += ch;
|
||||
backslash = false;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
};
|
||||
|
||||
function read_regexp() {
|
||||
return with_eof_error("Unterminated regular expression", function(){
|
||||
var prev_backslash = false, regexp = "", ch, in_class = false;
|
||||
|
@ -452,15 +509,14 @@ function tokenizer($TEXT, skip_comments) {
|
|||
} else {
|
||||
regexp += ch;
|
||||
}
|
||||
var mods = read_while(function(ch){
|
||||
return HOP(REGEXP_MODIFIERS, ch);
|
||||
});
|
||||
var mods = read_name();
|
||||
return token("regexp", [ regexp, mods ]);
|
||||
});
|
||||
};
|
||||
|
||||
function read_operator(prefix) {
|
||||
function grow(op) {
|
||||
if (!peek()) return op;
|
||||
var bigger = op + peek();
|
||||
if (HOP(OPERATORS, bigger)) {
|
||||
next();
|
||||
|
@ -472,19 +528,18 @@ function tokenizer($TEXT, skip_comments) {
|
|||
return token("operator", grow(prefix || next()));
|
||||
};
|
||||
|
||||
var handle_slash = skip_comments ? function() {
|
||||
function handle_slash() {
|
||||
next();
|
||||
var regex_allowed = S.regex_allowed;
|
||||
switch (peek()) {
|
||||
case "/": read_line_comment(); S.regex_allowed = regex_allowed; return next_token();
|
||||
case "*": read_multiline_comment(); S.regex_allowed = regex_allowed; return next_token();
|
||||
}
|
||||
return S.regex_allowed ? read_regexp() : read_operator("/");
|
||||
} : function() {
|
||||
next();
|
||||
switch (peek()) {
|
||||
case "/": return read_line_comment();
|
||||
case "*": return read_multiline_comment();
|
||||
case "/":
|
||||
S.comments_before.push(read_line_comment());
|
||||
S.regex_allowed = regex_allowed;
|
||||
return next_token();
|
||||
case "*":
|
||||
S.comments_before.push(read_multiline_comment());
|
||||
S.regex_allowed = regex_allowed;
|
||||
return next_token();
|
||||
}
|
||||
return S.regex_allowed ? read_regexp() : read_operator("/");
|
||||
};
|
||||
|
@ -497,7 +552,7 @@ function tokenizer($TEXT, skip_comments) {
|
|||
};
|
||||
|
||||
function read_word() {
|
||||
var word = read_while(is_identifier_char);
|
||||
var word = read_name();
|
||||
return !HOP(KEYWORDS, word)
|
||||
? token("name", word)
|
||||
: HOP(OPERATORS, word)
|
||||
|
@ -529,7 +584,7 @@ function tokenizer($TEXT, skip_comments) {
|
|||
if (ch == ".") return handle_dot();
|
||||
if (ch == "/") return handle_slash();
|
||||
if (HOP(OPERATOR_CHARS, ch)) return read_operator();
|
||||
if (is_identifier_char(ch)) return read_word();
|
||||
if (ch == "\\" || is_identifier_start(ch)) return read_word();
|
||||
parse_error("Unexpected character '" + ch + "'");
|
||||
};
|
||||
|
||||
|
@ -565,7 +620,7 @@ var ASSIGNMENT = (function(a, ret, i){
|
|||
}
|
||||
return ret;
|
||||
})(
|
||||
["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "~=", "%=", "|=", "^=", "&="],
|
||||
["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="],
|
||||
{ "=": true },
|
||||
0
|
||||
);
|
||||
|
@ -608,16 +663,16 @@ function NodeWithToken(str, start, end) {
|
|||
|
||||
NodeWithToken.prototype.toString = function() { return this.name; };
|
||||
|
||||
function parse($TEXT, strict_mode, embed_tokens) {
|
||||
function parse($TEXT, exigent_mode, embed_tokens) {
|
||||
|
||||
var S = {
|
||||
input: tokenizer($TEXT, true),
|
||||
token: null,
|
||||
prev: null,
|
||||
peeked: null,
|
||||
in_function: 0,
|
||||
in_loop: 0,
|
||||
labels: []
|
||||
input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT,
|
||||
token : null,
|
||||
prev : null,
|
||||
peeked : null,
|
||||
in_function : 0,
|
||||
in_loop : 0,
|
||||
labels : []
|
||||
};
|
||||
|
||||
S.token = next();
|
||||
|
@ -671,7 +726,7 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
function expect(punc) { return expect_token("punc", punc); };
|
||||
|
||||
function can_insert_semicolon() {
|
||||
return !strict_mode && (
|
||||
return !exigent_mode && (
|
||||
S.token.nlb || is("eof") || is("punc", "}")
|
||||
);
|
||||
};
|
||||
|
@ -693,17 +748,20 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
};
|
||||
|
||||
function add_tokens(str, start, end) {
|
||||
return new NodeWithToken(str, start, end);
|
||||
return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end);
|
||||
};
|
||||
|
||||
var statement = embed_tokens ? function() {
|
||||
var start = S.token;
|
||||
var stmt = $statement();
|
||||
stmt[0] = add_tokens(stmt[0], start, prev());
|
||||
return stmt;
|
||||
} : $statement;
|
||||
function maybe_embed_tokens(parser) {
|
||||
if (embed_tokens) return function() {
|
||||
var start = S.token;
|
||||
var ast = parser.apply(this, arguments);
|
||||
ast[0] = add_tokens(ast[0], start, prev());
|
||||
return ast;
|
||||
};
|
||||
else return parser;
|
||||
};
|
||||
|
||||
function $statement() {
|
||||
var statement = maybe_embed_tokens(function() {
|
||||
if (is("operator", "/")) {
|
||||
S.peeked = null;
|
||||
S.token = S.input(true); // force regexp
|
||||
|
@ -797,12 +855,12 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
unexpected();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
function labeled_statement(label) {
|
||||
S.labels.push(label);
|
||||
var start = S.token, stat = statement();
|
||||
if (strict_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0]))
|
||||
if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0]))
|
||||
unexpected(start);
|
||||
S.labels.pop();
|
||||
return as("label", label, stat);
|
||||
|
@ -827,29 +885,35 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
|
||||
function for_() {
|
||||
expect("(");
|
||||
var has_var = is("keyword", "var");
|
||||
if (has_var)
|
||||
next();
|
||||
if (is("name") && is_token(peek(), "operator", "in")) {
|
||||
// for (i in foo)
|
||||
var name = S.token.value;
|
||||
next(); next();
|
||||
var obj = expression();
|
||||
expect(")");
|
||||
return as("for-in", has_var, name, obj, in_loop(statement));
|
||||
} else {
|
||||
// classic for
|
||||
var init = is("punc", ";") ? null : has_var ? var_() : expression();
|
||||
expect(";");
|
||||
var test = is("punc", ";") ? null : expression();
|
||||
expect(";");
|
||||
var step = is("punc", ")") ? null : expression();
|
||||
expect(")");
|
||||
return as("for", init, test, step, in_loop(statement));
|
||||
var init = null;
|
||||
if (!is("punc", ";")) {
|
||||
init = is("keyword", "var")
|
||||
? (next(), var_(true))
|
||||
: expression(true, true);
|
||||
if (is("operator", "in"))
|
||||
return for_in(init);
|
||||
}
|
||||
return regular_for(init);
|
||||
};
|
||||
|
||||
function function_(in_statement) {
|
||||
function regular_for(init) {
|
||||
expect(";");
|
||||
var test = is("punc", ";") ? null : expression();
|
||||
expect(";");
|
||||
var step = is("punc", ")") ? null : expression();
|
||||
expect(")");
|
||||
return as("for", init, test, step, in_loop(statement));
|
||||
};
|
||||
|
||||
function for_in(init) {
|
||||
var lhs = init[0] == "var" ? as("name", init[1][0]) : init;
|
||||
next();
|
||||
var obj = expression();
|
||||
expect(")");
|
||||
return as("for-in", init, lhs, obj, in_loop(statement));
|
||||
};
|
||||
|
||||
var function_ = maybe_embed_tokens(function(in_statement) {
|
||||
var name = is("name") ? prog1(S.token.value, next) : null;
|
||||
if (in_statement && !name)
|
||||
unexpected();
|
||||
|
@ -877,7 +941,7 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
S.in_loop = loop;
|
||||
return a;
|
||||
})());
|
||||
};
|
||||
});
|
||||
|
||||
function if_() {
|
||||
var cond = parenthesised(), body = statement(), belse;
|
||||
|
@ -946,7 +1010,7 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
return as("try", body, bcatch, bfinally);
|
||||
};
|
||||
|
||||
function vardefs() {
|
||||
function vardefs(no_in) {
|
||||
var a = [];
|
||||
for (;;) {
|
||||
if (!is("name"))
|
||||
|
@ -955,7 +1019,7 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
next();
|
||||
if (is("operator", "=")) {
|
||||
next();
|
||||
a.push([ name, expression(false) ]);
|
||||
a.push([ name, expression(false, no_in) ]);
|
||||
} else {
|
||||
a.push([ name ]);
|
||||
}
|
||||
|
@ -966,8 +1030,8 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
return a;
|
||||
};
|
||||
|
||||
function var_() {
|
||||
return as("var", vardefs());
|
||||
function var_(no_in) {
|
||||
return as("var", vardefs(no_in));
|
||||
};
|
||||
|
||||
function const_() {
|
||||
|
@ -985,7 +1049,7 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
return subscripts(as("new", newexp, args), true);
|
||||
};
|
||||
|
||||
function expr_atom(allow_calls) {
|
||||
var expr_atom = maybe_embed_tokens(function(allow_calls) {
|
||||
if (is("operator", "new")) {
|
||||
next();
|
||||
return new_();
|
||||
|
@ -1020,29 +1084,32 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
return subscripts(prog1(atom, next), allow_calls);
|
||||
}
|
||||
unexpected();
|
||||
};
|
||||
});
|
||||
|
||||
function expr_list(closing, allow_trailing_comma) {
|
||||
function expr_list(closing, allow_trailing_comma, allow_empty) {
|
||||
var first = true, a = [];
|
||||
while (!is("punc", closing)) {
|
||||
if (first) first = false; else expect(",");
|
||||
if (allow_trailing_comma && is("punc", closing))
|
||||
break;
|
||||
a.push(expression(false));
|
||||
if (allow_trailing_comma && is("punc", closing)) break;
|
||||
if (is("punc", ",") && allow_empty) {
|
||||
a.push([ "atom", "undefined" ]);
|
||||
} else {
|
||||
a.push(expression(false));
|
||||
}
|
||||
}
|
||||
next();
|
||||
return a;
|
||||
};
|
||||
|
||||
function array_() {
|
||||
return as("array", expr_list("]", !strict_mode));
|
||||
return as("array", expr_list("]", !exigent_mode, true));
|
||||
};
|
||||
|
||||
function object_() {
|
||||
var first = true, a = [];
|
||||
while (!is("punc", "}")) {
|
||||
if (first) first = false; else expect(",");
|
||||
if (!strict_mode && is("punc", "}"))
|
||||
if (!exigent_mode && is("punc", "}"))
|
||||
// allow trailing comma
|
||||
break;
|
||||
var type = S.token.type;
|
||||
|
@ -1105,64 +1172,68 @@ function parse($TEXT, strict_mode, embed_tokens) {
|
|||
return as(tag, op, expr);
|
||||
};
|
||||
|
||||
function expr_op(left, min_prec) {
|
||||
function expr_op(left, min_prec, no_in) {
|
||||
var op = is("operator") ? S.token.value : null;
|
||||
if (op && op == "in" && no_in) op = null;
|
||||
var prec = op != null ? PRECEDENCE[op] : null;
|
||||
if (prec != null && prec > min_prec) {
|
||||
next();
|
||||
var right = expr_op(expr_atom(true), prec);
|
||||
return expr_op(as("binary", op, left, right), min_prec);
|
||||
var right = expr_op(expr_atom(true), prec, no_in);
|
||||
return expr_op(as("binary", op, left, right), min_prec, no_in);
|
||||
}
|
||||
return left;
|
||||
};
|
||||
|
||||
function expr_ops() {
|
||||
return expr_op(expr_atom(true), 0);
|
||||
function expr_ops(no_in) {
|
||||
return expr_op(expr_atom(true), 0, no_in);
|
||||
};
|
||||
|
||||
function maybe_conditional() {
|
||||
var expr = expr_ops();
|
||||
function maybe_conditional(no_in) {
|
||||
var expr = expr_ops(no_in);
|
||||
if (is("operator", "?")) {
|
||||
next();
|
||||
var yes = expression(false);
|
||||
expect(":");
|
||||
return as("conditional", expr, yes, expression(false));
|
||||
return as("conditional", expr, yes, expression(false, no_in));
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
function is_assignable(expr) {
|
||||
if (!exigent_mode) return true;
|
||||
switch (expr[0]) {
|
||||
case "dot":
|
||||
case "sub":
|
||||
case "new":
|
||||
case "call":
|
||||
return true;
|
||||
case "name":
|
||||
return expr[1] != "this";
|
||||
}
|
||||
};
|
||||
|
||||
function maybe_assign() {
|
||||
var left = maybe_conditional(), val = S.token.value;
|
||||
function maybe_assign(no_in) {
|
||||
var left = maybe_conditional(no_in), val = S.token.value;
|
||||
if (is("operator") && HOP(ASSIGNMENT, val)) {
|
||||
if (is_assignable(left)) {
|
||||
next();
|
||||
return as("assign", ASSIGNMENT[val], left, maybe_assign());
|
||||
return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in));
|
||||
}
|
||||
croak("Invalid assignment");
|
||||
}
|
||||
return left;
|
||||
};
|
||||
|
||||
function expression(commas) {
|
||||
var expression = maybe_embed_tokens(function(commas, no_in) {
|
||||
if (arguments.length == 0)
|
||||
commas = true;
|
||||
var expr = maybe_assign();
|
||||
var expr = maybe_assign(no_in);
|
||||
if (commas && is("punc", ",")) {
|
||||
next();
|
||||
return as("seq", expr, expression());
|
||||
return as("seq", expr, expression(true, no_in));
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
});
|
||||
|
||||
function in_loop(cont) {
|
||||
try {
|
||||
|
@ -1222,6 +1293,8 @@ function HOP(obj, prop) {
|
|||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
};
|
||||
|
||||
var warn = function() {};
|
||||
|
||||
/* -----[ Exports ]----- */
|
||||
|
||||
exports.tokenizer = tokenizer;
|
||||
|
@ -1237,3 +1310,6 @@ exports.KEYWORDS = KEYWORDS;
|
|||
exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN;
|
||||
exports.OPERATORS = OPERATORS;
|
||||
exports.is_alphanumeric_char = is_alphanumeric_char;
|
||||
exports.set_logger = function(logger) {
|
||||
warn = logger;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,4 +4,4 @@ var print = require("sys").print,
|
|||
src = require("fs").readFileSync(process.argv[2], "utf8");
|
||||
|
||||
// Previously done in sed but reimplemented here due to portability issues
|
||||
print(src.replace(/^(\s*\*\/)(.+)/m, "$1\n$2;"));
|
||||
print( src.replace( /^(\s*\*\/)(.+)/m, "$1\n$2" ) + ";" );
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env node
|
||||
/*
|
||||
* jQuery Release Note Generator
|
||||
*/
|
||||
|
||||
var fs = require("fs"),
|
||||
http = require("http"),
|
||||
tmpl = require("mustache"),
|
||||
extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g;
|
||||
|
||||
var opts = {
|
||||
version: "1.6.2 RC 1",
|
||||
short_version: "1.6.2rc1",
|
||||
final_version: "1.6.2",
|
||||
categories: []
|
||||
};
|
||||
|
||||
http.request({
|
||||
host: "bugs.jquery.com",
|
||||
port: 80,
|
||||
method: "GET",
|
||||
path: "/query?status=closed&resolution=fixed&component=!web&order=component&milestone=" + opts.final_version
|
||||
}, function (res) {
|
||||
var data = [];
|
||||
|
||||
res.on( "data", function( chunk ) {
|
||||
data.push( chunk );
|
||||
});
|
||||
|
||||
res.on( "end", function() {
|
||||
var match,
|
||||
file = data.join(""),
|
||||
cur;
|
||||
|
||||
while ( (match = extract.exec( file )) ) {
|
||||
if ( "#" + match[1] !== match[2] ) {
|
||||
var cat = match[3];
|
||||
|
||||
if ( !cur || cur.name !== cat ) {
|
||||
cur = { name: match[3], niceName: match[3].replace(/^./, function(a){ return a.toUpperCase(); }), bugs: [] };
|
||||
opts.categories.push( cur );
|
||||
}
|
||||
|
||||
cur.bugs.push({ ticket: match[1], title: match[2] });
|
||||
}
|
||||
}
|
||||
|
||||
buildNotes();
|
||||
});
|
||||
}).end();
|
||||
|
||||
function buildNotes() {
|
||||
console.log( tmpl.to_html( fs.readFileSync("release-notes.txt", "utf8"), opts ) );
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<h2>jQuery {{version}} Released</h2>
|
||||
|
||||
<p>This is a preview release of jQuery. We're releasing it so that everyone can start testing the code in their applications, making sure that there are no major problems.</p>
|
||||
|
||||
<p>You can get the code from the jQuery CDN:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://code.jquery.com/jquery-{{short_version}}.js">http://code.jquery.com/jquery-{{short_version}}.js</a></li>
|
||||
</ul>
|
||||
|
||||
<p>You can help us by dropping that code into your existing application and letting us know that if anything no longer works. Please <a href="http://bugs.jquery.com/">file a bug</a> and be sure to mention that you're testing against jQuery {{version}}.</p>
|
||||
|
||||
<p>We want to encourage everyone from the community to try and <a href="http://docs.jquery.com/Getting_Involved">get involved</a> in contributing back to jQuery core. We've set up a <a href="http://docs.jquery.com/Getting_Involved">full page</a> of information dedicated towards becoming more involved with the team. The team is here and ready to help you help us!</p>
|
||||
|
||||
<h2>jQuery {{version}} Change Log</h2>
|
||||
|
||||
<p>The current change log of the {{version}} release.</p>
|
||||
|
||||
{{#categories}}
|
||||
<h3>{{niceName}}</h3>
|
||||
|
||||
<ul>
|
||||
{{#bugs}}
|
||||
<li><a href="http://bugs.jquery.com/ticket/{{ticket}}">#{{ticket}}</a>: {{title}}</li>
|
||||
{{/bugs}}
|
||||
</ul>
|
||||
{{/categories}}
|
|
@ -0,0 +1,169 @@
|
|||
#!/usr/bin/env node
|
||||
/*
|
||||
* jQuery Release Management
|
||||
*/
|
||||
|
||||
var fs = require("fs"),
|
||||
child = require("child_process"),
|
||||
debug = false;
|
||||
|
||||
var scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/",
|
||||
cdnURL = "http://code.origin.jquery.com/",
|
||||
|
||||
version = /^[\d.]+(?:(?:a|b|rc)\d+|pre)?$/,
|
||||
versionFile = "version.txt",
|
||||
|
||||
file = "dist/jquery.js",
|
||||
minFile = "dist/jquery.min.js",
|
||||
|
||||
files = {
|
||||
"jquery-VER.js": file,
|
||||
"jquery-VER.min.js": minFile
|
||||
},
|
||||
|
||||
finalFiles = {
|
||||
"jquery.js": file,
|
||||
"jquery-latest.js": file,
|
||||
"jquery.min.js": minFile,
|
||||
"jquery-latest.min.js": minFile
|
||||
};
|
||||
|
||||
exec( "git pull && git status", function( error, stdout, stderr ) {
|
||||
if ( /Changes to be committed/i.test( stdout ) ) {
|
||||
exit( "Please commit changed files before attemping to push a release." );
|
||||
|
||||
} else if ( /Changes not staged for commit/i.test( stdout ) ) {
|
||||
exit( "Please stash files before attempting to push a release." );
|
||||
|
||||
} else {
|
||||
setVersion();
|
||||
}
|
||||
});
|
||||
|
||||
function setVersion() {
|
||||
var oldVersion = fs.readFileSync( versionFile, "utf8" );
|
||||
|
||||
prompt( "New Version (was " + oldVersion + "): ", function( data ) {
|
||||
if ( data && version.test( data ) ) {
|
||||
fs.writeFileSync( versionFile, data );
|
||||
|
||||
exec( "git commit -a -m 'Tagging the " + data + " release.' && git push && " +
|
||||
"git tag " + data + " && git push origin " + data, function() {
|
||||
make( data );
|
||||
});
|
||||
|
||||
} else {
|
||||
console.error( "Malformed version number, please try again." );
|
||||
setVersion();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function make( newVersion ) {
|
||||
exec( "make clean && make", function( error, stdout, stderr ) {
|
||||
// TODO: Verify JSLint
|
||||
|
||||
Object.keys( files ).forEach(function( oldName ) {
|
||||
var value = files[ oldName ], name = oldName.replace( /VER/g, newVersion );
|
||||
|
||||
copy( value, name );
|
||||
|
||||
delete files[ oldName ];
|
||||
files[ name ] = value;
|
||||
});
|
||||
|
||||
exec( "scp " + Object.keys( files ).join( " " ) + " " + scpURL, function() {
|
||||
setNextVersion( newVersion );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function setNextVersion( newVersion ) {
|
||||
var isFinal = false;
|
||||
|
||||
if ( /(?:a|b|rc)\d+$/.test( newVersion ) ) {
|
||||
newVersion = newVersion.replace( /(?:a|b|rc)\d+$/, "pre" );
|
||||
|
||||
} else if ( /^\d+\.\d+\.?(\d*)$/.test( newVersion ) ) {
|
||||
newVersion = newVersion.replace( /^(\d+\.\d+\.?)(\d*)$/, function( all, pre, num ) {
|
||||
return pre + (pre.charAt( pre.length - 1 ) !== "." ? "." : "") + (num ? parseFloat( num ) + 1 : 1) + "pre";
|
||||
});
|
||||
|
||||
isFinal = true;
|
||||
}
|
||||
|
||||
prompt( "Next Version [" + newVersion + "]: ", function( data ) {
|
||||
if ( !data ) {
|
||||
data = newVersion;
|
||||
}
|
||||
|
||||
if ( version.test( data ) ) {
|
||||
fs.writeFileSync( versionFile, data );
|
||||
|
||||
exec( "git commit -a -m 'Updating the source version to " + data + "' && git push", function() {
|
||||
if ( isFinal ) {
|
||||
makeFinal( newVersion );
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
console.error( "Malformed version number, please try again." );
|
||||
setNextVersion( newVersion );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function makeFinal( newVersion ) {
|
||||
var all = Object.keys( finalFiles );
|
||||
|
||||
// Copy all the files
|
||||
all.forEach(function( name ) {
|
||||
copy( finalFiles[ name ], name );
|
||||
});
|
||||
|
||||
// Upload files to CDN
|
||||
exec( "scp " + all.join( " " ) + " " + scpURL, function() {
|
||||
exec( "curl '" + cdnURL + "{" + all.join( "," ) + "}?reload'", function() {
|
||||
console.log( "Done." );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function copy( oldFile, newFile ) {
|
||||
if ( debug ) {
|
||||
console.log( "Copying " + oldFile + " to " + newFile );
|
||||
|
||||
} else {
|
||||
fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) );
|
||||
}
|
||||
}
|
||||
|
||||
function prompt( msg, callback ) {
|
||||
process.stdout.write( msg );
|
||||
|
||||
process.stdin.resume();
|
||||
process.stdin.setEncoding( "utf8" );
|
||||
|
||||
process.stdin.once( "data", function( chunk ) {
|
||||
process.stdin.pause();
|
||||
callback( chunk.replace( /\n*$/g, "" ) );
|
||||
});
|
||||
}
|
||||
|
||||
function exec( cmd, fn ) {
|
||||
if ( debug ) {
|
||||
console.log( cmd );
|
||||
fn();
|
||||
|
||||
} else {
|
||||
child.exec( cmd, fn );
|
||||
}
|
||||
}
|
||||
|
||||
function exit( msg ) {
|
||||
if ( msg ) {
|
||||
console.error( "\nError: " + msg );
|
||||
}
|
||||
|
||||
process.exit( 1 );
|
||||
}
|
176
build/uglify.js
176
build/uglify.js
|
@ -1,14 +1,10 @@
|
|||
#! /usr/bin/env node
|
||||
// -*- js2 -*-
|
||||
// -*- js -*-
|
||||
|
||||
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
|
||||
var fs = require("fs"),
|
||||
jsp = require("./lib/parse-js"),
|
||||
pro = require("./lib/process");
|
||||
|
||||
pro.set_logger(function(msg){
|
||||
sys.debug(msg);
|
||||
});
|
||||
var fs = require("fs");
|
||||
var jsp = require("./lib/parse-js"),
|
||||
pro = require("./lib/process");
|
||||
|
||||
var options = {
|
||||
ast: false,
|
||||
|
@ -17,13 +13,16 @@ var options = {
|
|||
squeeze: true,
|
||||
make_seqs: true,
|
||||
dead_code: true,
|
||||
beautify: false,
|
||||
verbose: false,
|
||||
show_copyright: true,
|
||||
out_same_file: false,
|
||||
extra: false,
|
||||
unsafe: false, // XXX: extra & unsafe? but maybe we don't want both, so....
|
||||
beautify_options: {
|
||||
max_line_length: 32 * 1024,
|
||||
unsafe: false,
|
||||
reserved_names: null,
|
||||
defines: { },
|
||||
codegen_options: {
|
||||
ascii_only: false,
|
||||
beautify: false,
|
||||
indent_level: 4,
|
||||
indent_start: 0,
|
||||
quote_keys: false,
|
||||
|
@ -40,15 +39,15 @@ out: while (args.length > 0) {
|
|||
switch (v) {
|
||||
case "-b":
|
||||
case "--beautify":
|
||||
options.beautify = true;
|
||||
options.codegen_options.beautify = true;
|
||||
break;
|
||||
case "-i":
|
||||
case "--indent":
|
||||
options.beautify_options.indent_level = args.shift();
|
||||
options.codegen_options.indent_level = args.shift();
|
||||
break;
|
||||
case "-q":
|
||||
case "--quote-keys":
|
||||
options.beautify_options.quote_keys = true;
|
||||
options.codegen_options.quote_keys = true;
|
||||
break;
|
||||
case "-mt":
|
||||
case "--mangle-toplevel":
|
||||
|
@ -86,23 +85,109 @@ out: while (args.length > 0) {
|
|||
case "--ast":
|
||||
options.ast = true;
|
||||
break;
|
||||
case "--extra":
|
||||
options.extra = true;
|
||||
break;
|
||||
case "--unsafe":
|
||||
options.unsafe = true;
|
||||
break;
|
||||
case "--max-line-len":
|
||||
options.max_line_length = parseInt(args.shift(), 10);
|
||||
break;
|
||||
case "--reserved-names":
|
||||
options.reserved_names = args.shift().split(",");
|
||||
break;
|
||||
case "-d":
|
||||
case "--define":
|
||||
var defarg = args.shift();
|
||||
try {
|
||||
var defsym = function(sym) {
|
||||
// KEYWORDS_ATOM doesn't include NaN or Infinity - should we check
|
||||
// for them too ?? We don't check reserved words and the like as the
|
||||
// define values are only substituted AFTER parsing
|
||||
if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) {
|
||||
throw "Don't define values for inbuilt constant '"+sym+"'";
|
||||
}
|
||||
return sym;
|
||||
},
|
||||
defval = function(v) {
|
||||
if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) {
|
||||
return [ "string", RegExp.$1 ];
|
||||
}
|
||||
else if (!isNaN(parseFloat(v))) {
|
||||
return [ "num", parseFloat(v) ];
|
||||
}
|
||||
else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) {
|
||||
return [ "name", v ];
|
||||
}
|
||||
else if (!v.match(/"/)) {
|
||||
return [ "string", v ];
|
||||
}
|
||||
else if (!v.match(/'/)) {
|
||||
return [ "string", v ];
|
||||
}
|
||||
throw "Can't understand the specified value: "+v;
|
||||
};
|
||||
if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) {
|
||||
var sym = defsym(RegExp.$1),
|
||||
val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ];
|
||||
options.defines[sym] = val;
|
||||
}
|
||||
else {
|
||||
throw "The --define option expects SYMBOL[=value]";
|
||||
}
|
||||
} catch(ex) {
|
||||
sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n");
|
||||
process.exit(1);
|
||||
}
|
||||
break;
|
||||
case "--define-from-module":
|
||||
var defmodarg = args.shift(),
|
||||
defmodule = require(defmodarg),
|
||||
sym,
|
||||
val;
|
||||
for (sym in defmodule) {
|
||||
if (defmodule.hasOwnProperty(sym)) {
|
||||
options.defines[sym] = function(val) {
|
||||
if (typeof val == "string")
|
||||
return [ "string", val ];
|
||||
if (typeof val == "number")
|
||||
return [ "num", val ];
|
||||
if (val === true)
|
||||
return [ 'name', 'true' ];
|
||||
if (val === false)
|
||||
return [ 'name', 'false' ];
|
||||
if (val === null)
|
||||
return [ 'name', 'null' ];
|
||||
if (val === undefined)
|
||||
return [ 'name', 'undefined' ];
|
||||
sys.print("ERROR: In option --define-from-module "+defmodarg+"\n");
|
||||
sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n");
|
||||
process.exit(1);
|
||||
return null;
|
||||
}(defmodule[sym]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "--ascii":
|
||||
options.codegen_options.ascii_only = true;
|
||||
break;
|
||||
default:
|
||||
filename = v;
|
||||
break out;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.verbose) {
|
||||
pro.set_logger(function(msg){
|
||||
sys.debug(msg);
|
||||
});
|
||||
}
|
||||
|
||||
jsp.set_logger(function(msg){
|
||||
sys.debug(msg);
|
||||
});
|
||||
|
||||
if (filename) {
|
||||
fs.readFile(filename, "utf8", function(err, text){
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
if (err) throw err;
|
||||
output(squeeze_it(text));
|
||||
});
|
||||
} else {
|
||||
|
@ -131,7 +216,9 @@ function output(text) {
|
|||
});
|
||||
}
|
||||
out.write(text);
|
||||
out.end();
|
||||
if (options.output !== true) {
|
||||
out.end();
|
||||
}
|
||||
};
|
||||
|
||||
// --------- main ends here.
|
||||
|
@ -152,36 +239,35 @@ function show_copyright(comments) {
|
|||
function squeeze_it(code) {
|
||||
var result = "";
|
||||
if (options.show_copyright) {
|
||||
var initial_comments = [];
|
||||
// keep first comment
|
||||
var tok = jsp.tokenizer(code, false), c;
|
||||
var tok = jsp.tokenizer(code), c;
|
||||
c = tok();
|
||||
var prev = null;
|
||||
while (/^comment/.test(c.type) && (!prev || prev == c.type)) {
|
||||
initial_comments.push(c);
|
||||
prev = c.type;
|
||||
c = tok();
|
||||
}
|
||||
result += show_copyright(initial_comments);
|
||||
result += show_copyright(c.comments_before);
|
||||
}
|
||||
try {
|
||||
var ast = time_it("parse", function(){ return jsp.parse(code); });
|
||||
if (options.mangle)
|
||||
ast = time_it("mangle", function(){ return pro.ast_mangle(ast, options.mangle_toplevel); });
|
||||
if (options.squeeze)
|
||||
ast = time_it("squeeze", function(){
|
||||
ast = pro.ast_squeeze(ast, {
|
||||
make_seqs : options.make_seqs,
|
||||
dead_code : options.dead_code,
|
||||
extra : options.extra
|
||||
});
|
||||
if (options.unsafe)
|
||||
ast = pro.ast_squeeze_more(ast);
|
||||
return ast;
|
||||
if (options.mangle) ast = time_it("mangle", function(){
|
||||
return pro.ast_mangle(ast, {
|
||||
toplevel: options.mangle_toplevel,
|
||||
defines: options.defines,
|
||||
except: options.reserved_names
|
||||
});
|
||||
});
|
||||
if (options.squeeze) ast = time_it("squeeze", function(){
|
||||
ast = pro.ast_squeeze(ast, {
|
||||
make_seqs : options.make_seqs,
|
||||
dead_code : options.dead_code,
|
||||
keep_comps : !options.unsafe
|
||||
});
|
||||
if (options.unsafe)
|
||||
ast = pro.ast_squeeze_more(ast);
|
||||
return ast;
|
||||
});
|
||||
if (options.ast)
|
||||
return sys.inspect(ast, null, null);
|
||||
result += time_it("generate", function(){ return pro.gen_code(ast, options.beautify && options.beautify_options) });
|
||||
result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
|
||||
if (!options.codegen_options.beautify && options.max_line_length) {
|
||||
result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
|
||||
}
|
||||
return result;
|
||||
} catch(ex) {
|
||||
sys.debug(ex.stack);
|
||||
|
|
51
src/ajax.js
51
src/ajax.js
|
@ -5,9 +5,9 @@ var r20 = /%20/g,
|
|||
rCRLF = /\r?\n/g,
|
||||
rhash = /#.*$/,
|
||||
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
||||
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
||||
rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
||||
// #7653, #8125, #8152: local protocol detection
|
||||
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
|
||||
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
|
||||
rnoContent = /^(?:GET|HEAD)$/,
|
||||
rprotocol = /^\/\//,
|
||||
rquery = /\?/,
|
||||
|
@ -15,10 +15,6 @@ var r20 = /%20/g,
|
|||
rselectTextarea = /^(?:select|textarea)/i,
|
||||
rspacesAjax = /\s+/,
|
||||
rts = /([?&])_=[^&]*/,
|
||||
rucHeaders = /(^|\-)([a-z])/g,
|
||||
rucHeadersFunc = function( _, $1, $2 ) {
|
||||
return $1 + $2.toUpperCase();
|
||||
},
|
||||
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
|
||||
|
||||
// Keep a copy of the old load method
|
||||
|
@ -49,9 +45,9 @@ var r20 = /%20/g,
|
|||
ajaxLocParts;
|
||||
|
||||
// #8138, IE may throw an exception when accessing
|
||||
// a field from document.location if document.domain has been set
|
||||
// a field from window.location if document.domain has been set
|
||||
try {
|
||||
ajaxLocation = document.location.href;
|
||||
ajaxLocation = location.href;
|
||||
} catch( e ) {
|
||||
// Use the href attribute of an A element
|
||||
// since IE will modify it given document.location
|
||||
|
@ -99,7 +95,7 @@ function addToPrefiltersOrTransports( structure ) {
|
|||
};
|
||||
}
|
||||
|
||||
//Base inspection function for prefilters and transports
|
||||
// Base inspection function for prefilters and transports
|
||||
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
|
||||
dataType /* internal */, inspected /* internal */ ) {
|
||||
|
||||
|
@ -393,6 +389,7 @@ jQuery.extend({
|
|||
ifModifiedKey,
|
||||
// Headers (they are sent all at once)
|
||||
requestHeaders = {},
|
||||
requestHeadersNames = {},
|
||||
// Response headers
|
||||
responseHeadersString,
|
||||
responseHeaders,
|
||||
|
@ -416,7 +413,9 @@ jQuery.extend({
|
|||
// Caches the header
|
||||
setRequestHeader: function( name, value ) {
|
||||
if ( !state ) {
|
||||
requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
|
||||
var lname = name.toLowerCase();
|
||||
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
||||
requestHeaders[ name ] = value;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
@ -645,6 +644,8 @@ jQuery.extend({
|
|||
// If data is available, append data to url
|
||||
if ( s.data ) {
|
||||
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
|
||||
// #9682: remove data so that it's not used in an eventual retry
|
||||
delete s.data;
|
||||
}
|
||||
|
||||
// Get ifModifiedKey before adding the anti-cache parameter
|
||||
|
@ -664,24 +665,27 @@ jQuery.extend({
|
|||
|
||||
// Set the correct header, if data is being sent
|
||||
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
||||
requestHeaders[ "Content-Type" ] = s.contentType;
|
||||
jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
||||
}
|
||||
|
||||
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
||||
if ( s.ifModified ) {
|
||||
ifModifiedKey = ifModifiedKey || s.url;
|
||||
if ( jQuery.lastModified[ ifModifiedKey ] ) {
|
||||
requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ];
|
||||
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
|
||||
}
|
||||
if ( jQuery.etag[ ifModifiedKey ] ) {
|
||||
requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ];
|
||||
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
|
||||
}
|
||||
}
|
||||
|
||||
// Set the Accepts header for the server, depending on the dataType
|
||||
requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
||||
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
|
||||
s.accepts[ "*" ];
|
||||
jqXHR.setRequestHeader(
|
||||
"Accept",
|
||||
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
||||
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
|
||||
s.accepts[ "*" ]
|
||||
);
|
||||
|
||||
// Check for headers option
|
||||
for ( i in s.headers ) {
|
||||
|
@ -725,7 +729,7 @@ jQuery.extend({
|
|||
transport.send( requestHeaders, done );
|
||||
} catch (e) {
|
||||
// Propagate exception as error if not done
|
||||
if ( status < 2 ) {
|
||||
if ( state < 2 ) {
|
||||
done( -1, e );
|
||||
// Simply rethrow otherwise
|
||||
} else {
|
||||
|
@ -773,7 +777,7 @@ jQuery.extend({
|
|||
});
|
||||
|
||||
function buildParams( prefix, obj, traditional, add ) {
|
||||
if ( jQuery.isArray( obj ) && obj.length ) {
|
||||
if ( jQuery.isArray( obj ) ) {
|
||||
// Serialize array item.
|
||||
jQuery.each( obj, function( i, v ) {
|
||||
if ( traditional || rbracket.test( prefix ) ) {
|
||||
|
@ -793,16 +797,9 @@ function buildParams( prefix, obj, traditional, add ) {
|
|||
});
|
||||
|
||||
} else if ( !traditional && obj != null && typeof obj === "object" ) {
|
||||
// If we see an array here, it is empty and should be treated as an empty
|
||||
// object
|
||||
if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) {
|
||||
add( prefix, "" );
|
||||
|
||||
// Serialize object item.
|
||||
} else {
|
||||
for ( var name in obj ) {
|
||||
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
||||
}
|
||||
for ( var name in obj ) {
|
||||
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -1,21 +1,14 @@
|
|||
(function( jQuery ) {
|
||||
|
||||
var // #5280: next active xhr id and list of active xhrs' callbacks
|
||||
xhrId = jQuery.now(),
|
||||
xhrCallbacks,
|
||||
|
||||
// XHR used to determine supports properties
|
||||
testXHR;
|
||||
|
||||
// #5280: Internet Explorer will keep connections alive if we don't abort on unload
|
||||
function xhrOnUnloadAbort() {
|
||||
jQuery( window ).unload(function() {
|
||||
var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
|
||||
xhrOnUnloadAbort = window.ActiveXObject ? function() {
|
||||
// Abort all pending requests
|
||||
for ( var key in xhrCallbacks ) {
|
||||
xhrCallbacks[ key ]( 0, 1 );
|
||||
}
|
||||
});
|
||||
}
|
||||
} : false,
|
||||
xhrId = 0,
|
||||
xhrCallbacks;
|
||||
|
||||
// Functions to create xhrs
|
||||
function createStandardXHR() {
|
||||
|
@ -45,15 +38,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ?
|
|||
// For all other browsers, use the standard XMLHttpRequest object
|
||||
createStandardXHR;
|
||||
|
||||
// Test if we can create an xhr object
|
||||
testXHR = jQuery.ajaxSettings.xhr();
|
||||
jQuery.support.ajax = !!testXHR;
|
||||
|
||||
// Does this browser support crossDomain XHR requests
|
||||
jQuery.support.cors = testXHR && ( "withCredentials" in testXHR );
|
||||
|
||||
// No need for the temporary xhr anymore
|
||||
testXHR = undefined;
|
||||
// Determine support properties
|
||||
(function( xhr ) {
|
||||
jQuery.extend( jQuery.support, {
|
||||
ajax: !!xhr,
|
||||
cors: !!xhr && ( "withCredentials" in xhr )
|
||||
});
|
||||
})( jQuery.ajaxSettings.xhr() );
|
||||
|
||||
// Create transport if the browser can provide an xhr
|
||||
if ( jQuery.support.ajax ) {
|
||||
|
@ -136,7 +127,9 @@ if ( jQuery.support.ajax ) {
|
|||
// Do not keep as active anymore
|
||||
if ( handle ) {
|
||||
xhr.onreadystatechange = jQuery.noop;
|
||||
delete xhrCallbacks[ handle ];
|
||||
if ( xhrOnUnloadAbort ) {
|
||||
delete xhrCallbacks[ handle ];
|
||||
}
|
||||
}
|
||||
|
||||
// If it's an abort
|
||||
|
@ -197,15 +190,18 @@ if ( jQuery.support.ajax ) {
|
|||
if ( !s.async || xhr.readyState === 4 ) {
|
||||
callback();
|
||||
} else {
|
||||
// Create the active xhrs callbacks list if needed
|
||||
// and attach the unload handler
|
||||
if ( !xhrCallbacks ) {
|
||||
xhrCallbacks = {};
|
||||
xhrOnUnloadAbort();
|
||||
handle = ++xhrId;
|
||||
if ( xhrOnUnloadAbort ) {
|
||||
// Create the active xhrs callbacks list if needed
|
||||
// and attach the unload handler
|
||||
if ( !xhrCallbacks ) {
|
||||
xhrCallbacks = {};
|
||||
jQuery( window ).unload( xhrOnUnloadAbort );
|
||||
}
|
||||
// Add to list of active xhrs callbacks
|
||||
xhrCallbacks[ handle ] = callback;
|
||||
}
|
||||
// Add to list of active xhrs callbacks
|
||||
handle = xhrId++;
|
||||
xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
|
||||
xhr.onreadystatechange = callback;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
(function( jQuery ) {
|
||||
|
||||
var rclass = /[\n\t\r]/g,
|
||||
rspaces = /\s+/,
|
||||
rspace = /\s+/,
|
||||
rreturn = /\r/g,
|
||||
rtype = /^(?:button|input)$/i,
|
||||
rfocusable = /^(?:button|input|object|select|textarea)$/i,
|
||||
rclickable = /^a(?:rea)?$/i,
|
||||
formHook;
|
||||
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
|
||||
rinvalidChar = /\:|^on/,
|
||||
formHook, boolHook;
|
||||
|
||||
jQuery.fn.extend({
|
||||
attr: function( name, value ) {
|
||||
|
@ -24,6 +26,7 @@ jQuery.fn.extend({
|
|||
},
|
||||
|
||||
removeProp: function( name ) {
|
||||
name = jQuery.propFix[ name ] || name;
|
||||
return this.each(function() {
|
||||
// try/catch handles cases where IE balks (such as removing a property on window)
|
||||
try {
|
||||
|
@ -34,30 +37,31 @@ jQuery.fn.extend({
|
|||
},
|
||||
|
||||
addClass: function( value ) {
|
||||
var classNames, i, l, elem,
|
||||
setClass, c, cl;
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each(function(i) {
|
||||
var self = jQuery(this);
|
||||
self.addClass( value.call(this, i, self.attr("class") || "") );
|
||||
return this.each(function( j ) {
|
||||
jQuery( this ).addClass( value.call(this, j, this.className) );
|
||||
});
|
||||
}
|
||||
|
||||
if ( value && typeof value === "string" ) {
|
||||
var classNames = (value || "").split( rspaces );
|
||||
classNames = value.split( rspace );
|
||||
|
||||
for ( var i = 0, l = this.length; i < l; i++ ) {
|
||||
var elem = this[i];
|
||||
for ( i = 0, l = this.length; i < l; i++ ) {
|
||||
elem = this[ i ];
|
||||
|
||||
if ( elem.nodeType === 1 ) {
|
||||
if ( !elem.className ) {
|
||||
if ( !elem.className && classNames.length === 1 ) {
|
||||
elem.className = value;
|
||||
|
||||
} else {
|
||||
var className = " " + elem.className + " ",
|
||||
setClass = elem.className;
|
||||
setClass = " " + elem.className + " ";
|
||||
|
||||
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
|
||||
if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
|
||||
setClass += " " + classNames[c];
|
||||
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
|
||||
if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
|
||||
setClass += classNames[ c ] + " ";
|
||||
}
|
||||
}
|
||||
elem.className = jQuery.trim( setClass );
|
||||
|
@ -70,24 +74,25 @@ jQuery.fn.extend({
|
|||
},
|
||||
|
||||
removeClass: function( value ) {
|
||||
if ( jQuery.isFunction(value) ) {
|
||||
return this.each(function(i) {
|
||||
var self = jQuery(this);
|
||||
self.removeClass( value.call(this, i, self.attr("class")) );
|
||||
var classNames, i, l, elem, className, c, cl;
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each(function( j ) {
|
||||
jQuery( this ).removeClass( value.call(this, j, this.className) );
|
||||
});
|
||||
}
|
||||
|
||||
if ( (value && typeof value === "string") || value === undefined ) {
|
||||
var classNames = (value || "").split( rspaces );
|
||||
classNames = (value || "").split( rspace );
|
||||
|
||||
for ( var i = 0, l = this.length; i < l; i++ ) {
|
||||
var elem = this[i];
|
||||
for ( i = 0, l = this.length; i < l; i++ ) {
|
||||
elem = this[ i ];
|
||||
|
||||
if ( elem.nodeType === 1 && elem.className ) {
|
||||
if ( value ) {
|
||||
var className = (" " + elem.className + " ").replace(rclass, " ");
|
||||
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
|
||||
className = className.replace(" " + classNames[c] + " ", " ");
|
||||
className = (" " + elem.className + " ").replace( rclass, " " );
|
||||
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
|
||||
className = className.replace(" " + classNames[ c ] + " ", " ");
|
||||
}
|
||||
elem.className = jQuery.trim( className );
|
||||
|
||||
|
@ -106,9 +111,8 @@ jQuery.fn.extend({
|
|||
isBool = typeof stateVal === "boolean";
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each(function(i) {
|
||||
var self = jQuery(this);
|
||||
self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
|
||||
return this.each(function( i ) {
|
||||
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -119,7 +123,7 @@ jQuery.fn.extend({
|
|||
i = 0,
|
||||
self = jQuery( this ),
|
||||
state = stateVal,
|
||||
classNames = value.split( rspaces );
|
||||
classNames = value.split( rspace );
|
||||
|
||||
while ( (className = classNames[ i++ ]) ) {
|
||||
// check each className given, space seperated list
|
||||
|
@ -158,11 +162,17 @@ jQuery.fn.extend({
|
|||
if ( elem ) {
|
||||
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
|
||||
|
||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem )) !== undefined ) {
|
||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return (elem.value || "").replace(rreturn, "");
|
||||
ret = elem.value;
|
||||
|
||||
return typeof ret === "string" ?
|
||||
// handle most common string cases
|
||||
ret.replace(rreturn, "") :
|
||||
// handle cases where value is null/undef or number
|
||||
ret == null ? "" : ret;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
@ -197,7 +207,7 @@ jQuery.fn.extend({
|
|||
hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
|
||||
|
||||
// If set returns undefined, fall back to normal setting
|
||||
if ( !hooks || ("set" in hooks && hooks.set( this, val ) === undefined) ) {
|
||||
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
|
||||
this.value = val;
|
||||
}
|
||||
});
|
||||
|
@ -216,7 +226,8 @@ jQuery.extend({
|
|||
},
|
||||
select: {
|
||||
get: function( elem ) {
|
||||
var index = elem.selectedIndex,
|
||||
var value,
|
||||
index = elem.selectedIndex,
|
||||
values = [],
|
||||
options = elem.options,
|
||||
one = elem.type === "select-one";
|
||||
|
@ -283,8 +294,7 @@ jQuery.extend({
|
|||
|
||||
attrFix: {
|
||||
// Always normalize to ensure hook usage
|
||||
tabindex: "tabIndex",
|
||||
readonly: "readOnly"
|
||||
tabindex: "tabIndex"
|
||||
},
|
||||
|
||||
attr: function( elem, name, value, pass ) {
|
||||
|
@ -298,16 +308,35 @@ jQuery.extend({
|
|||
if ( pass && name in jQuery.attrFn ) {
|
||||
return jQuery( elem )[ name ]( value );
|
||||
}
|
||||
|
||||
|
||||
// Fallback to prop when attributes are not supported
|
||||
if ( !("getAttribute" in elem) ) {
|
||||
return jQuery.prop( elem, name, value );
|
||||
}
|
||||
|
||||
var ret, hooks,
|
||||
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
||||
|
||||
// Normalize the name if needed
|
||||
name = notxml && jQuery.attrFix[ name ] || name;
|
||||
|
||||
// Get the appropriate hook, or the formHook
|
||||
// if getSetAttribute is not supported and we have form objects in IE6/7
|
||||
hooks = jQuery.attrHooks[ name ] || ( elem.nodeName === "FORM" && formHook );
|
||||
// Normalize the name if needed
|
||||
if ( notxml ) {
|
||||
name = jQuery.attrFix[ name ] || name;
|
||||
|
||||
hooks = jQuery.attrHooks[ name ];
|
||||
|
||||
if ( !hooks ) {
|
||||
// Use boolHook for boolean attributes
|
||||
if ( rboolean.test( name ) ) {
|
||||
|
||||
hooks = boolHook;
|
||||
|
||||
// Use formHook for forms and if the name contains certain characters
|
||||
} else if ( formHook && name !== "className" &&
|
||||
(jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
|
||||
|
||||
hooks = formHook;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( value !== undefined ) {
|
||||
|
||||
|
@ -323,24 +352,22 @@ jQuery.extend({
|
|||
return value;
|
||||
}
|
||||
|
||||
} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
|
||||
if ( hooks && "get" in hooks && notxml ) {
|
||||
return hooks.get( elem, name );
|
||||
ret = elem.getAttribute( name );
|
||||
|
||||
} else {
|
||||
|
||||
ret = elem.getAttribute( name );
|
||||
|
||||
// Non-existent attributes return null, we normalize to undefined
|
||||
return ret === null ?
|
||||
undefined :
|
||||
ret;
|
||||
}
|
||||
// Non-existent attributes return null, we normalize to undefined
|
||||
return ret === null ?
|
||||
undefined :
|
||||
ret;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
removeAttr: function( elem, name ) {
|
||||
var propName;
|
||||
if ( elem.nodeType === 1 ) {
|
||||
name = jQuery.attrFix[ name ] || name;
|
||||
|
||||
|
@ -351,6 +378,11 @@ jQuery.extend({
|
|||
jQuery.attr( elem, name, "" );
|
||||
elem.removeAttributeNode( elem.getAttributeNode( name ) );
|
||||
}
|
||||
|
||||
// Set corresponding property to false for boolean attributes
|
||||
if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
|
||||
elem[ propName ] = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -360,6 +392,16 @@ jQuery.extend({
|
|||
// We can't allow the type property to be changed (since it causes problems in IE)
|
||||
if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
|
||||
jQuery.error( "type property can't be changed" );
|
||||
} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
|
||||
// Setting the type on a radio button after the value resets the value in IE6-9
|
||||
// Reset value to it's default in case type is set after value
|
||||
// This is for element creation
|
||||
var val = elem.value;
|
||||
elem.setAttribute( "type", value );
|
||||
if ( val ) {
|
||||
elem.value = val;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -375,39 +417,72 @@ jQuery.extend({
|
|||
0 :
|
||||
undefined;
|
||||
}
|
||||
},
|
||||
// Use the value property for back compat
|
||||
// Use the formHook for button elements in IE6/7 (#1954)
|
||||
value: {
|
||||
get: function( elem, name ) {
|
||||
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
|
||||
return formHook.get( elem, name );
|
||||
}
|
||||
return name in elem ?
|
||||
elem.value :
|
||||
null;
|
||||
},
|
||||
set: function( elem, value, name ) {
|
||||
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
|
||||
return formHook.set( elem, value, name );
|
||||
}
|
||||
// Does not return so that setAttribute is also used
|
||||
elem.value = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
propFix: {},
|
||||
|
||||
propFix: {
|
||||
tabindex: "tabIndex",
|
||||
readonly: "readOnly",
|
||||
"for": "htmlFor",
|
||||
"class": "className",
|
||||
maxlength: "maxLength",
|
||||
cellspacing: "cellSpacing",
|
||||
cellpadding: "cellPadding",
|
||||
rowspan: "rowSpan",
|
||||
colspan: "colSpan",
|
||||
usemap: "useMap",
|
||||
frameborder: "frameBorder",
|
||||
contenteditable: "contentEditable"
|
||||
},
|
||||
|
||||
prop: function( elem, name, value ) {
|
||||
var nType = elem.nodeType;
|
||||
|
||||
|
||||
// don't get/set properties on text, comment and attribute nodes
|
||||
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
var ret, hooks,
|
||||
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
||||
|
||||
// Try to normalize/fix the name
|
||||
name = notxml && jQuery.propFix[ name ] || name;
|
||||
|
||||
hooks = jQuery.propHooks[ name ];
|
||||
|
||||
|
||||
if ( notxml ) {
|
||||
// Fix name and attach hooks
|
||||
name = jQuery.propFix[ name ] || name;
|
||||
hooks = jQuery.propHooks[ name ];
|
||||
}
|
||||
|
||||
if ( value !== undefined ) {
|
||||
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
||||
return ret;
|
||||
|
||||
|
||||
} else {
|
||||
return (elem[ name ] = value);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) {
|
||||
return ret;
|
||||
|
||||
|
||||
} else {
|
||||
return elem[ name ];
|
||||
}
|
||||
|
@ -417,26 +492,47 @@ jQuery.extend({
|
|||
propHooks: {}
|
||||
});
|
||||
|
||||
// Hook for boolean attributes
|
||||
boolHook = {
|
||||
get: function( elem, name ) {
|
||||
// Align boolean attributes with corresponding properties
|
||||
return jQuery.prop( elem, name ) ?
|
||||
name.toLowerCase() :
|
||||
undefined;
|
||||
},
|
||||
set: function( elem, value, name ) {
|
||||
var propName;
|
||||
if ( value === false ) {
|
||||
// Remove boolean attributes when set to false
|
||||
jQuery.removeAttr( elem, name );
|
||||
} else {
|
||||
// value is true since we know at this point it's type boolean and not false
|
||||
// Set boolean attributes to the same name and set the DOM property
|
||||
propName = jQuery.propFix[ name ] || name;
|
||||
if ( propName in elem ) {
|
||||
// Only set the IDL specifically if it already exists on the element
|
||||
elem[ propName ] = true;
|
||||
}
|
||||
|
||||
elem.setAttribute( name, name.toLowerCase() );
|
||||
}
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
// IE6/7 do not support getting/setting some attributes with get/setAttribute
|
||||
if ( !jQuery.support.getSetAttribute ) {
|
||||
jQuery.attrFix = jQuery.extend( jQuery.attrFix, {
|
||||
"for": "htmlFor",
|
||||
"class": "className",
|
||||
maxlength: "maxLength",
|
||||
cellspacing: "cellSpacing",
|
||||
rowspan: "rowSpan",
|
||||
colspan: "colSpan",
|
||||
usemap: "useMap",
|
||||
frameborder: "frameBorder"
|
||||
});
|
||||
|
||||
// propFix is more comprehensive and contains all fixes
|
||||
jQuery.attrFix = jQuery.propFix;
|
||||
|
||||
// Use this for any attribute on a form in IE6/7
|
||||
// And the name attribute
|
||||
formHook = jQuery.attrHooks.name = {
|
||||
formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = {
|
||||
get: function( elem, name ) {
|
||||
var ret = elem.getAttributeNode( name );
|
||||
// Return undefined if not specified instead of empty string
|
||||
return ret && ret.specified ?
|
||||
var ret;
|
||||
ret = elem.getAttributeNode( name );
|
||||
// Return undefined if nodeValue is empty string
|
||||
return ret && ret.nodeValue !== "" ?
|
||||
ret.nodeValue :
|
||||
undefined;
|
||||
},
|
||||
|
@ -465,17 +561,6 @@ if ( !jQuery.support.getSetAttribute ) {
|
|||
});
|
||||
}
|
||||
|
||||
// Remove certain attrs if set to false
|
||||
jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name ) {
|
||||
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
|
||||
set: function( elem, value ) {
|
||||
if ( value === false ) {
|
||||
jQuery.removeAttr( elem, name );
|
||||
return value;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Some attributes require a special call on IE
|
||||
if ( !jQuery.support.hrefNormalized ) {
|
||||
|
|
66
src/core.js
66
src/core.js
|
@ -44,6 +44,14 @@ var jQuery = function( selector, context ) {
|
|||
rmsie = /(msie) ([\w.]+)/,
|
||||
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
|
||||
|
||||
// Matches dashed string for camelizing
|
||||
rdashAlpha = /-([a-z])/ig,
|
||||
|
||||
// Used by jQuery.camelCase as callback to replace()
|
||||
fcamelCase = function( all, letter ) {
|
||||
return letter.toUpperCase();
|
||||
},
|
||||
|
||||
// Keep a UserAgent string for use with jQuery.browser
|
||||
userAgent = navigator.userAgent,
|
||||
|
||||
|
@ -96,9 +104,10 @@ jQuery.fn = jQuery.prototype = {
|
|||
// Handle HTML strings
|
||||
if ( typeof selector === "string" ) {
|
||||
// Are we dealing with HTML string or an ID?
|
||||
if ( selector.length > 1024 ) {
|
||||
// Assume very large strings are HTML and skip the regex check
|
||||
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
|
||||
// Assume that strings that start and end with <> are HTML and skip the regex check
|
||||
match = [ null, selector, null ];
|
||||
|
||||
} else {
|
||||
match = quickExpr.exec( selector );
|
||||
}
|
||||
|
@ -581,6 +590,12 @@ jQuery.extend({
|
|||
}
|
||||
},
|
||||
|
||||
// Converts a dashed string to camelCased string;
|
||||
// Used by both the css and data modules
|
||||
camelCase: function( string ) {
|
||||
return string.replace( rdashAlpha, fcamelCase );
|
||||
},
|
||||
|
||||
nodeName: function( elem, name ) {
|
||||
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
||||
},
|
||||
|
@ -719,7 +734,7 @@ jQuery.extend({
|
|||
i = 0,
|
||||
length = elems.length,
|
||||
// jquery objects are treated as arrays
|
||||
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || jQuery.isArray( elems ) ) ;
|
||||
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
|
||||
|
||||
// Go through the array, translating each of the items to their
|
||||
if ( isArray ) {
|
||||
|
@ -731,7 +746,7 @@ jQuery.extend({
|
|||
}
|
||||
}
|
||||
|
||||
// Go thorugh every key on the object,
|
||||
// Go through every key on the object,
|
||||
} else {
|
||||
for ( key in elems ) {
|
||||
value = callback( elems[ key ], key, arg );
|
||||
|
@ -752,45 +767,23 @@ jQuery.extend({
|
|||
// Bind a function to a context, optionally partially applying any
|
||||
// arguments.
|
||||
proxy: function( fn, context ) {
|
||||
var args, proxy;
|
||||
|
||||
// XXX BACKCOMPAT: Support old string method.
|
||||
if ( typeof context === "string" ) {
|
||||
fn = fn[ context ];
|
||||
context = arguments[0];
|
||||
var tmp = fn[ context ];
|
||||
context = fn;
|
||||
fn = tmp;
|
||||
}
|
||||
|
||||
// Quick check to determine if target is callable, in the spec
|
||||
// this throws a TypeError, but we will just return undefined.
|
||||
if ( ! jQuery.isFunction( fn ) ) {
|
||||
if ( !jQuery.isFunction( fn ) ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if ( jQuery.support.nativeBind ) {
|
||||
// Native bind
|
||||
args = slice.call( arguments, 1 );
|
||||
if ( args.length ) {
|
||||
proxy = Function.prototype.bind.apply( fn, args );
|
||||
} else {
|
||||
proxy = fn.bind( context );
|
||||
}
|
||||
} else {
|
||||
// Simulated bind
|
||||
args = slice.call( arguments, 2 );
|
||||
if ( args.length ) {
|
||||
proxy = function() {
|
||||
return arguments.length ?
|
||||
fn.apply( context, args.concat( slice.call( arguments ) ) ) :
|
||||
fn.apply( context, args );
|
||||
};
|
||||
} else {
|
||||
proxy = function() {
|
||||
return arguments.length ?
|
||||
fn.apply( context, arguments ) :
|
||||
fn.call( context );
|
||||
};
|
||||
}
|
||||
}
|
||||
// Simulated bind
|
||||
var args = slice.call( arguments, 2 ),
|
||||
proxy = function() {
|
||||
return fn.apply( context, args.concat( slice.call( arguments ) ) );
|
||||
};
|
||||
|
||||
// Set the guid of unique handler to the same of original handler, so it can be removed
|
||||
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
|
||||
|
@ -799,7 +792,7 @@ jQuery.extend({
|
|||
},
|
||||
|
||||
// Mutifunctional method to get and set values to a collection
|
||||
// The value/s can be optionally by executed if its a function
|
||||
// The value/s can optionally be executed if it's a function
|
||||
access: function( elems, key, value, exec, fn, pass ) {
|
||||
var length = elems.length;
|
||||
|
||||
|
@ -930,7 +923,6 @@ function doScrollCheck() {
|
|||
jQuery.ready();
|
||||
}
|
||||
|
||||
// Expose jQuery to the global object
|
||||
return jQuery;
|
||||
|
||||
})();
|
||||
|
|
126
src/css.js
126
src/css.js
|
@ -2,14 +2,12 @@
|
|||
|
||||
var ralpha = /alpha\([^)]*\)/i,
|
||||
ropacity = /opacity=([^)]*)/,
|
||||
rdashAlpha = /-([a-z])/ig,
|
||||
// fixed for IE9, see #8346
|
||||
rupper = /([A-Z]|^ms)/g,
|
||||
rnumpx = /^-?\d+(?:px)?$/i,
|
||||
rnum = /^-?\d/,
|
||||
rrelNum = /^[+\-]=/,
|
||||
rrelNumFilter = /[^+\-\.\de]+/g,
|
||||
rinputbutton = /input|button/i,
|
||||
|
||||
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
||||
cssWidth = [ "Left", "Right" ],
|
||||
|
@ -17,11 +15,7 @@ var ralpha = /alpha\([^)]*\)/i,
|
|||
curCSS,
|
||||
|
||||
getComputedStyle,
|
||||
currentStyle,
|
||||
|
||||
fcamelCase = function( all, letter ) {
|
||||
return letter.toUpperCase();
|
||||
};
|
||||
currentStyle;
|
||||
|
||||
jQuery.fn.css = function( name, value ) {
|
||||
// Setting 'undefined' is a no-op
|
||||
|
@ -56,11 +50,14 @@ jQuery.extend({
|
|||
|
||||
// Exclude the following css properties to add px
|
||||
cssNumber: {
|
||||
"zIndex": true,
|
||||
"fillOpacity": true,
|
||||
"fontWeight": true,
|
||||
"lineHeight": true,
|
||||
"opacity": true,
|
||||
"zoom": true,
|
||||
"lineHeight": true
|
||||
"orphans": true,
|
||||
"widows": true,
|
||||
"zIndex": true,
|
||||
"zoom": true
|
||||
},
|
||||
|
||||
// Add in properties whose names you wish to fix before
|
||||
|
@ -95,6 +92,8 @@ jQuery.extend({
|
|||
// convert relative number strings (+= or -=) to relative numbers. #7345
|
||||
if ( type === "string" && rrelNum.test( value ) ) {
|
||||
value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) );
|
||||
// Fixes bug #9237
|
||||
type = "number";
|
||||
}
|
||||
|
||||
// If a number was passed in, add 'px' to the (except for certain CSS properties)
|
||||
|
@ -161,10 +160,6 @@ jQuery.extend({
|
|||
for ( name in options ) {
|
||||
elem.style[ name ] = old[ name ];
|
||||
}
|
||||
},
|
||||
|
||||
camelCase: function( string ) {
|
||||
return string.replace( rdashAlpha, fcamelCase );
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -178,44 +173,21 @@ jQuery.each(["height", "width"], function( i, name ) {
|
|||
|
||||
if ( computed ) {
|
||||
if ( elem.offsetWidth !== 0 ) {
|
||||
val = getWH( elem, name, extra );
|
||||
|
||||
return getWH( elem, name, extra );
|
||||
} else {
|
||||
jQuery.swap( elem, cssShow, function() {
|
||||
val = getWH( elem, name, extra );
|
||||
});
|
||||
}
|
||||
|
||||
if ( val <= 0 ) {
|
||||
val = curCSS( elem, name, name );
|
||||
|
||||
if ( val === "0px" && currentStyle ) {
|
||||
val = currentStyle( elem, name, name );
|
||||
}
|
||||
|
||||
if ( val != null ) {
|
||||
// Should return "auto" instead of 0, use 0 for
|
||||
// temporary backwards-compat
|
||||
return val === "" || val === "auto" ? "0px" : val;
|
||||
}
|
||||
}
|
||||
|
||||
if ( val < 0 || val == null ) {
|
||||
val = elem.style[ name ];
|
||||
|
||||
// Should return "auto" instead of 0, use 0 for
|
||||
// temporary backwards-compat
|
||||
return val === "" || val === "auto" ? "0px" : val;
|
||||
}
|
||||
|
||||
return typeof val === "string" ? val : val + "px";
|
||||
return val;
|
||||
}
|
||||
},
|
||||
|
||||
set: function( elem, value ) {
|
||||
if ( rnumpx.test( value ) ) {
|
||||
// ignore negative width and height values #1599
|
||||
value = parseFloat(value);
|
||||
value = parseFloat( value );
|
||||
|
||||
if ( value >= 0 ) {
|
||||
return value + "px";
|
||||
|
@ -338,48 +310,50 @@ if ( document.documentElement.currentStyle ) {
|
|||
curCSS = getComputedStyle || currentStyle;
|
||||
|
||||
function getWH( elem, name, extra ) {
|
||||
var which = name === "width" ? cssWidth : cssHeight,
|
||||
cur = curCSS( elem, name ),
|
||||
|
||||
// We're addressing the way Firefox handles certain inputs and buttons,
|
||||
// offsetWidth/height actually returns a normal width/height
|
||||
boxSizing = rinputbutton.test( elem.nodeName ) &&
|
||||
( curCSS( elem, "-moz-box-sizing" ) === "border-box" ||
|
||||
curCSS( elem, "box-sizing" ) === "border-box" );
|
||||
|
||||
// IE will return auto if we try to grab a width/height that is not set
|
||||
if ( boxSizing || cur === "auto" ) {
|
||||
cur = name === "width" ? elem.offsetWidth : elem.offsetHeight;
|
||||
}
|
||||
// Start with offset property
|
||||
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
||||
which = name === "width" ? cssWidth : cssHeight;
|
||||
|
||||
// Make sure that IE7 returns the correct computed value for display
|
||||
if ( name === "height" ) {
|
||||
elem.offsetHeight;
|
||||
}
|
||||
|
||||
var val = parseFloat( cur ) || 0;
|
||||
|
||||
if ( extra ) {
|
||||
for ( var i = 0, len = which.length; i < len ; i++ ) {
|
||||
var dir = which[i];
|
||||
|
||||
// outerWidth/height
|
||||
if ( extra === "border" || extra === "margin" ) {
|
||||
val += parseFloat(jQuery.css( elem, "border" + dir + "Width" )) || 0;
|
||||
val += parseFloat(jQuery.css( elem, "padding" + dir )) || 0;
|
||||
|
||||
if ( extra == "margin" ) {
|
||||
val += parseFloat(jQuery.css( elem, "margin" + dir )) || 0;
|
||||
if ( val > 0 ) {
|
||||
if ( extra !== "border" ) {
|
||||
jQuery.each( which, function() {
|
||||
if ( !extra ) {
|
||||
val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
|
||||
}
|
||||
|
||||
// innerWidth/height
|
||||
} else {
|
||||
val += parseFloat(jQuery.css( elem, "padding" + dir )) || 0;
|
||||
}
|
||||
if ( extra === "margin" ) {
|
||||
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
|
||||
} else {
|
||||
val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return val + "px";
|
||||
}
|
||||
|
||||
return val;
|
||||
// Fall back to computed then uncomputed css if necessary
|
||||
val = curCSS( elem, name, name );
|
||||
if ( val < 0 || val == null ) {
|
||||
val = elem.style[ name ] || 0;
|
||||
}
|
||||
// Normalize "", auto, and prepare for extra
|
||||
val = parseFloat( val ) || 0;
|
||||
|
||||
// Add padding, border, margin
|
||||
if ( extra ) {
|
||||
jQuery.each( which, function() {
|
||||
val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
|
||||
if ( extra !== "padding" ) {
|
||||
val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
|
||||
}
|
||||
if ( extra === "margin" ) {
|
||||
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return val + "px";
|
||||
}
|
||||
|
||||
if ( jQuery.expr && jQuery.expr.filters ) {
|
||||
|
|
|
@ -98,7 +98,7 @@ jQuery.extend({
|
|||
}
|
||||
|
||||
if ( data !== undefined ) {
|
||||
thisCache[ name ] = data;
|
||||
thisCache[ jQuery.camelCase( name ) ] = data;
|
||||
}
|
||||
|
||||
// TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
|
||||
|
@ -108,7 +108,10 @@ jQuery.extend({
|
|||
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
|
||||
}
|
||||
|
||||
return getByName ? thisCache[ name ] : thisCache;
|
||||
return getByName ?
|
||||
// Check for both converted-to-camel and non-converted data property names
|
||||
thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] :
|
||||
thisCache;
|
||||
},
|
||||
|
||||
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
|
||||
|
@ -284,7 +287,7 @@ function dataAttr( elem, key, data ) {
|
|||
// If nothing was found internally, try to fetch any
|
||||
// data from the HTML5 data-* attribute
|
||||
if ( data === undefined && elem.nodeType === 1 ) {
|
||||
name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
|
||||
var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
|
||||
|
||||
data = elem.getAttribute( name );
|
||||
|
||||
|
|
|
@ -119,10 +119,10 @@ jQuery.extend({
|
|||
if ( jQuery.isFunction( fn ) ) {
|
||||
deferred[ handler ](function() {
|
||||
returned = fn.apply( this, arguments );
|
||||
if ( jQuery.isFunction( returned.promise ) ) {
|
||||
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
||||
returned.promise().then( newDefer.resolve, newDefer.reject );
|
||||
} else {
|
||||
newDefer[ action ]( returned );
|
||||
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
(function( jQuery ) {
|
||||
|
||||
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
||||
// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
|
||||
jQuery.each([ "Height", "Width" ], function( i, name ) {
|
||||
|
||||
var type = name.toLowerCase();
|
||||
|
||||
// innerHeight and innerWidth
|
||||
jQuery.fn["inner" + name] = function() {
|
||||
return this[0] ?
|
||||
parseFloat( jQuery.css( this[0], type, "padding" ) ) :
|
||||
jQuery.fn[ "inner" + name ] = function() {
|
||||
var elem = this[0];
|
||||
return elem && elem.style ?
|
||||
parseFloat( jQuery.css( elem, type, "padding" ) ) :
|
||||
null;
|
||||
};
|
||||
|
||||
// outerHeight and outerWidth
|
||||
jQuery.fn["outer" + name] = function( margin ) {
|
||||
return this[0] ?
|
||||
parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
|
||||
jQuery.fn[ "outer" + name ] = function( margin ) {
|
||||
var elem = this[0];
|
||||
return elem && elem.style ?
|
||||
parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
|
||||
null;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
(function( jQuery ) {
|
||||
|
||||
var elemdisplay = {},
|
||||
iframe = null,
|
||||
iframeDoc = null,
|
||||
iframe, iframeDoc,
|
||||
rfxtypes = /^(?:toggle|show|hide)$/,
|
||||
rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
|
||||
timerId,
|
||||
|
@ -16,17 +15,8 @@ var elemdisplay = {},
|
|||
],
|
||||
fxNow,
|
||||
requestAnimationFrame = window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame;
|
||||
|
||||
function clearFxNow() {
|
||||
fxNow = undefined;
|
||||
}
|
||||
|
||||
function createFxNow() {
|
||||
setTimeout( clearFxNow, 0 );
|
||||
return ( fxNow = jQuery.now() );
|
||||
}
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame;
|
||||
|
||||
jQuery.fn.extend({
|
||||
show: function( speed, easing, callback ) {
|
||||
|
@ -38,19 +28,22 @@ jQuery.fn.extend({
|
|||
} else {
|
||||
for ( var i = 0, j = this.length; i < j; i++ ) {
|
||||
elem = this[i];
|
||||
display = elem.style.display;
|
||||
|
||||
// Reset the inline display of this element to learn if it is
|
||||
// being hidden by cascaded rules or not
|
||||
if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
|
||||
display = elem.style.display = "";
|
||||
}
|
||||
if ( elem.style ) {
|
||||
display = elem.style.display;
|
||||
|
||||
// Set elements which have been overridden with display: none
|
||||
// in a stylesheet to whatever the default browser style is
|
||||
// for such an element
|
||||
if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
|
||||
jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
|
||||
// Reset the inline display of this element to learn if it is
|
||||
// being hidden by cascaded rules or not
|
||||
if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
|
||||
display = elem.style.display = "";
|
||||
}
|
||||
|
||||
// Set elements which have been overridden with display: none
|
||||
// in a stylesheet to whatever the default browser style is
|
||||
// for such an element
|
||||
if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
|
||||
jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,10 +51,13 @@ jQuery.fn.extend({
|
|||
// to avoid the constant reflow
|
||||
for ( i = 0; i < j; i++ ) {
|
||||
elem = this[i];
|
||||
display = elem.style.display;
|
||||
|
||||
if ( display === "" || display === "none" ) {
|
||||
elem.style.display = jQuery._data(elem, "olddisplay") || "";
|
||||
if ( elem.style ) {
|
||||
display = elem.style.display;
|
||||
|
||||
if ( display === "" || display === "none" ) {
|
||||
elem.style.display = jQuery._data(elem, "olddisplay") || "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,17 +71,21 @@ jQuery.fn.extend({
|
|||
|
||||
} else {
|
||||
for ( var i = 0, j = this.length; i < j; i++ ) {
|
||||
var display = jQuery.css( this[i], "display" );
|
||||
if ( this[i].style ) {
|
||||
var display = jQuery.css( this[i], "display" );
|
||||
|
||||
if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
|
||||
jQuery._data( this[i], "olddisplay", display );
|
||||
if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
|
||||
jQuery._data( this[i], "olddisplay", display );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the display of the elements in a second loop
|
||||
// to avoid the constant reflow
|
||||
for ( i = 0; i < j; i++ ) {
|
||||
this[i].style.display = "none";
|
||||
if ( this[i].style ) {
|
||||
this[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -126,6 +126,9 @@ jQuery.fn.extend({
|
|||
return this.each( optall.complete, [ false ] );
|
||||
}
|
||||
|
||||
// Do not change referenced properties as per-property easing will be lost
|
||||
prop = jQuery.extend( {}, prop );
|
||||
|
||||
return this[ optall.queue === false ? "each" : "queue" ](function() {
|
||||
// XXX 'this' does not always have a nodeName when running the
|
||||
// test suite
|
||||
|
@ -134,25 +137,40 @@ jQuery.fn.extend({
|
|||
jQuery._mark( this );
|
||||
}
|
||||
|
||||
var opt = jQuery.extend({}, optall), p,
|
||||
var opt = jQuery.extend( {}, optall ),
|
||||
isElement = this.nodeType === 1,
|
||||
hidden = isElement && jQuery(this).is(":hidden"),
|
||||
self = this;
|
||||
name, val, p,
|
||||
display, e,
|
||||
parts, start, end, unit;
|
||||
|
||||
// will store per property easing and be used to determine when an animation is complete
|
||||
opt.animatedProperties = {};
|
||||
|
||||
for ( p in prop ) {
|
||||
var name = jQuery.camelCase( p );
|
||||
|
||||
// property name normalization
|
||||
name = jQuery.camelCase( p );
|
||||
if ( p !== name ) {
|
||||
prop[ name ] = prop[ p ];
|
||||
delete prop[ p ];
|
||||
p = name;
|
||||
}
|
||||
|
||||
if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
|
||||
return opt.complete.call(this);
|
||||
val = prop[ name ];
|
||||
|
||||
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
|
||||
if ( jQuery.isArray( val ) ) {
|
||||
opt.animatedProperties[ name ] = val[ 1 ];
|
||||
val = prop[ name ] = val[ 0 ];
|
||||
} else {
|
||||
opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
|
||||
}
|
||||
|
||||
if ( isElement && ( p === "height" || p === "width" ) ) {
|
||||
if ( val === "hide" && hidden || val === "show" && !hidden ) {
|
||||
return opt.complete.call( this );
|
||||
}
|
||||
|
||||
if ( isElement && ( name === "height" || name === "width" ) ) {
|
||||
// Make sure that nothing sneaks out
|
||||
// Record all 3 overflow attributes because IE does not
|
||||
// change the overflow attribute when overflowX and
|
||||
|
@ -168,7 +186,7 @@ jQuery.fn.extend({
|
|||
this.style.display = "inline-block";
|
||||
|
||||
} else {
|
||||
var display = defaultDisplay(this.nodeName);
|
||||
display = defaultDisplay( this.nodeName );
|
||||
|
||||
// inline-level elements accept inline-block;
|
||||
// block-level elements need to be inline with layout
|
||||
|
@ -182,44 +200,37 @@ jQuery.fn.extend({
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( jQuery.isArray( prop[p] ) ) {
|
||||
// Create (if needed) and add to specialEasing
|
||||
(opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
|
||||
prop[p] = prop[p][0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( opt.overflow != null ) {
|
||||
this.style.overflow = "hidden";
|
||||
}
|
||||
|
||||
opt.curAnim = jQuery.extend({}, prop);
|
||||
|
||||
jQuery.each( prop, function( name, val ) {
|
||||
var e = new jQuery.fx( self, opt, name );
|
||||
for ( p in prop ) {
|
||||
e = new jQuery.fx( this, opt, p );
|
||||
val = prop[ p ];
|
||||
|
||||
if ( rfxtypes.test(val) ) {
|
||||
e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
|
||||
e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
|
||||
|
||||
} else {
|
||||
var parts = rfxnum.exec(val),
|
||||
start = e.cur();
|
||||
parts = rfxnum.exec( val );
|
||||
start = e.cur();
|
||||
|
||||
if ( parts ) {
|
||||
var end = parseFloat( parts[2] ),
|
||||
unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
|
||||
end = parseFloat( parts[2] );
|
||||
unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
|
||||
|
||||
// We need to compute starting value
|
||||
if ( unit !== "px" ) {
|
||||
jQuery.style( self, name, (end || 1) + unit);
|
||||
jQuery.style( this, p, (end || 1) + unit);
|
||||
start = ((end || 1) / e.cur()) * start;
|
||||
jQuery.style( self, name, start + unit);
|
||||
jQuery.style( this, p, start + unit);
|
||||
}
|
||||
|
||||
// If a +=/-= token was provided, we're doing a relative animation
|
||||
if ( parts[1] ) {
|
||||
end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
|
||||
end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
|
||||
}
|
||||
|
||||
e.custom( start, end, unit );
|
||||
|
@ -228,7 +239,7 @@ jQuery.fn.extend({
|
|||
e.custom( start, val, "" );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// For JS strict compliance
|
||||
return true;
|
||||
|
@ -236,19 +247,18 @@ jQuery.fn.extend({
|
|||
},
|
||||
|
||||
stop: function( clearQueue, gotoEnd ) {
|
||||
var timers = jQuery.timers;
|
||||
|
||||
if ( clearQueue ) {
|
||||
this.queue([]);
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
var timers = jQuery.timers,
|
||||
i = timers.length;
|
||||
// clear marker counters if we know they won't be
|
||||
if ( !gotoEnd ) {
|
||||
jQuery._unmark( true, this );
|
||||
}
|
||||
// go in reverse order so anything added to the queue during the loop is ignored
|
||||
for ( var i = timers.length - 1; i >= 0; i-- ) {
|
||||
while ( i-- ) {
|
||||
if ( timers[i].elem === this ) {
|
||||
if (gotoEnd) {
|
||||
// force the next step to be the last
|
||||
|
@ -270,6 +280,17 @@ jQuery.fn.extend({
|
|||
|
||||
});
|
||||
|
||||
// Animations created synchronously will run synchronously
|
||||
function createFxNow() {
|
||||
setTimeout( clearFxNow, 0 );
|
||||
return ( fxNow = jQuery.now() );
|
||||
}
|
||||
|
||||
function clearFxNow() {
|
||||
fxNow = undefined;
|
||||
}
|
||||
|
||||
// Generate parameters to create a standard animation
|
||||
function genFx( type, num ) {
|
||||
var obj = {};
|
||||
|
||||
|
@ -309,15 +330,15 @@ jQuery.extend({
|
|||
// Queueing
|
||||
opt.old = opt.complete;
|
||||
opt.complete = function( noUnmark ) {
|
||||
if ( jQuery.isFunction( opt.old ) ) {
|
||||
opt.old.call( this );
|
||||
}
|
||||
|
||||
if ( opt.queue !== false ) {
|
||||
jQuery.dequeue( this );
|
||||
} else if ( noUnmark !== false ) {
|
||||
jQuery._unmark( this );
|
||||
}
|
||||
|
||||
if ( jQuery.isFunction( opt.old ) ) {
|
||||
opt.old.call( this );
|
||||
}
|
||||
};
|
||||
|
||||
return opt;
|
||||
|
@ -339,9 +360,7 @@ jQuery.extend({
|
|||
this.elem = elem;
|
||||
this.prop = prop;
|
||||
|
||||
if ( !options.orig ) {
|
||||
options.orig = {};
|
||||
}
|
||||
options.orig = options.orig || {};
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -392,7 +411,7 @@ jQuery.fx.prototype = {
|
|||
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
||||
// Use requestAnimationFrame instead of setInterval if available
|
||||
if ( requestAnimationFrame ) {
|
||||
timerId = 1;
|
||||
timerId = true;
|
||||
raf = function() {
|
||||
// When timerId gets set to null at any point, this stops
|
||||
if ( timerId ) {
|
||||
|
@ -435,26 +454,27 @@ jQuery.fx.prototype = {
|
|||
// Each step of an animation
|
||||
step: function( gotoEnd ) {
|
||||
var t = fxNow || createFxNow(),
|
||||
done = true;
|
||||
done = true,
|
||||
elem = this.elem,
|
||||
options = this.options,
|
||||
i, n;
|
||||
|
||||
if ( gotoEnd || t >= this.options.duration + this.startTime ) {
|
||||
if ( gotoEnd || t >= options.duration + this.startTime ) {
|
||||
this.now = this.end;
|
||||
this.pos = this.state = 1;
|
||||
this.update();
|
||||
|
||||
this.options.curAnim[ this.prop ] = true;
|
||||
options.animatedProperties[ this.prop ] = true;
|
||||
|
||||
for ( var i in this.options.curAnim ) {
|
||||
if ( this.options.curAnim[i] !== true ) {
|
||||
for ( i in options.animatedProperties ) {
|
||||
if ( options.animatedProperties[i] !== true ) {
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( done ) {
|
||||
// Reset the overflow
|
||||
if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
|
||||
var elem = this.elem,
|
||||
options = this.options;
|
||||
if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
|
||||
|
||||
jQuery.each( [ "", "X", "Y" ], function (index, value) {
|
||||
elem.style[ "overflow" + value ] = options.overflow[index];
|
||||
|
@ -462,33 +482,35 @@ jQuery.fx.prototype = {
|
|||
}
|
||||
|
||||
// Hide the element if the "hide" operation was done
|
||||
if ( this.options.hide ) {
|
||||
jQuery(this.elem).hide();
|
||||
if ( options.hide ) {
|
||||
jQuery(elem).hide();
|
||||
}
|
||||
|
||||
// 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.style( this.elem, p, this.options.orig[p] );
|
||||
if ( options.hide || options.show ) {
|
||||
for ( var p in options.animatedProperties ) {
|
||||
jQuery.style( elem, p, options.orig[p] );
|
||||
}
|
||||
}
|
||||
|
||||
// Execute the complete function
|
||||
this.options.complete.call( this.elem );
|
||||
options.complete.call( elem );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} else {
|
||||
var n = t - this.startTime;
|
||||
this.state = n / this.options.duration;
|
||||
|
||||
// Perform the easing function, defaults to swing
|
||||
var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
|
||||
var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
|
||||
this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
|
||||
this.now = this.start + ((this.end - this.start) * this.pos);
|
||||
// classical easing cannot be used with an Infinity duration
|
||||
if ( options.duration == Infinity ) {
|
||||
this.now = t;
|
||||
} else {
|
||||
n = t - this.startTime;
|
||||
this.state = n / options.duration;
|
||||
|
||||
// Perform the easing function, defaults to swing
|
||||
this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
|
||||
this.now = this.start + ((this.end - this.start) * this.pos);
|
||||
}
|
||||
// Perform the next step of the animation
|
||||
this.update();
|
||||
}
|
||||
|
@ -499,9 +521,7 @@ jQuery.fx.prototype = {
|
|||
|
||||
jQuery.extend( jQuery.fx, {
|
||||
tick: function() {
|
||||
var timers = jQuery.timers;
|
||||
|
||||
for ( var i = 0; i < timers.length; i++ ) {
|
||||
for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
|
||||
if ( !timers[i]() ) {
|
||||
timers.splice(i--, 1);
|
||||
}
|
||||
|
@ -549,35 +569,35 @@ if ( jQuery.expr && jQuery.expr.filters ) {
|
|||
};
|
||||
}
|
||||
|
||||
// Try to restore the default display value of an element
|
||||
function defaultDisplay( nodeName ) {
|
||||
|
||||
if ( !elemdisplay[ nodeName ] ) {
|
||||
|
||||
var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
|
||||
var body = document.body,
|
||||
elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
|
||||
display = elem.css( "display" );
|
||||
|
||||
elem.remove();
|
||||
|
||||
// If the simple way fails,
|
||||
// get element's real default display by attaching it to a temp iframe
|
||||
if ( display === "none" || display === "" ) {
|
||||
|
||||
// Get element's real default display by attaching it to a temp iframe
|
||||
// Conritbutions from Louis Remi and Julian Aurbourg
|
||||
// based on recommendation by Louis Remi
|
||||
|
||||
// No iframe to use yet, so create it
|
||||
if ( !iframe ) {
|
||||
iframe = document.createElement( "iframe" );
|
||||
iframe.frameBorder = iframe.width = iframe.height = 0;
|
||||
}
|
||||
|
||||
document.body.appendChild( iframe );
|
||||
body.appendChild( iframe );
|
||||
|
||||
// Create a cacheable copy of the iframe document on first call.
|
||||
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
|
||||
// document to it, Webkit & Firefox won't allow reusing the iframe document
|
||||
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
|
||||
// document to it; WebKit & Firefox won't allow reusing the iframe document.
|
||||
if ( !iframeDoc || !iframe.createElement ) {
|
||||
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
|
||||
iframeDoc.write( "<!doctype><html><body></body></html>" );
|
||||
iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
|
||||
iframeDoc.close();
|
||||
}
|
||||
|
||||
elem = iframeDoc.createElement( nodeName );
|
||||
|
@ -586,7 +606,7 @@ function defaultDisplay( nodeName ) {
|
|||
|
||||
display = jQuery.css( elem, "display" );
|
||||
|
||||
document.body.removeChild( iframe );
|
||||
body.removeChild( iframe );
|
||||
}
|
||||
|
||||
// Store the correct default display
|
||||
|
@ -596,6 +616,4 @@ function defaultDisplay( nodeName ) {
|
|||
return elemdisplay[ nodeName ];
|
||||
}
|
||||
|
||||
|
||||
|
||||
})( jQuery );
|
||||
|
|
109
src/event.js
109
src/event.js
|
@ -1,10 +1,9 @@
|
|||
(function( jQuery ) {
|
||||
|
||||
var hasOwn = Object.prototype.hasOwnProperty,
|
||||
rnamespaces = /\.(.*)$/,
|
||||
var rnamespaces = /\.(.*)$/,
|
||||
rformElems = /^(?:textarea|input|select)$/i,
|
||||
rperiod = /\./g,
|
||||
rspace = / /g,
|
||||
rspaces = / /g,
|
||||
rescape = /[^\w\s.|`]/g,
|
||||
fcleanup = function( nm ) {
|
||||
return nm.replace(rescape, "\\$&");
|
||||
|
@ -63,7 +62,7 @@ jQuery.event = {
|
|||
elemData.handle = eventHandle = function( e ) {
|
||||
// Discard the second event of a jQuery.event.trigger() and
|
||||
// when an event is called after a page has unloaded
|
||||
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
|
||||
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
|
||||
jQuery.event.handle.apply( eventHandle.elem, arguments ) :
|
||||
undefined;
|
||||
};
|
||||
|
@ -275,7 +274,7 @@ jQuery.event = {
|
|||
"changeData": true
|
||||
},
|
||||
|
||||
trigger: function( event, data, elem ) {
|
||||
trigger: function( event, data, elem, onlyHandlers ) {
|
||||
// Event object or event type
|
||||
var type = event.type || event,
|
||||
namespaces = [],
|
||||
|
@ -294,7 +293,7 @@ jQuery.event = {
|
|||
namespaces.sort();
|
||||
}
|
||||
|
||||
if ( jQuery.event.customEvent[ type ] && !jQuery.event.global[ type ] ) {
|
||||
if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
|
||||
// No jQuery handlers for this event type, and it can't have inline handlers
|
||||
return;
|
||||
}
|
||||
|
@ -309,30 +308,29 @@ jQuery.event = {
|
|||
new jQuery.Event( type );
|
||||
|
||||
event.type = type;
|
||||
event.exclusive = exclusive;
|
||||
event.namespace = namespaces.join(".");
|
||||
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
||||
event.exclusive = exclusive;
|
||||
|
||||
// triggerHandler() and global events don't bubble or run the default action
|
||||
if ( onlyHandlers || !elem ) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
// Handle a global trigger
|
||||
if ( !elem ) {
|
||||
// Don't bubble custom events when global (to avoid too much overhead)
|
||||
event.stopPropagation();
|
||||
|
||||
// Save some time, only trigger if we've ever bound an event for this type
|
||||
if ( jQuery.event.global[ type ] ) {
|
||||
// XXX This code smells terrible. event.js should not be directly
|
||||
// inspecting the data cache
|
||||
jQuery.each( jQuery.cache, function() {
|
||||
// internalKey variable is just used to make it easier to find
|
||||
// and potentially change this stuff later; currently it just
|
||||
// points to jQuery.expando
|
||||
var internalKey = jQuery.expando,
|
||||
internalCache = this[ internalKey ];
|
||||
if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
|
||||
jQuery.event.trigger( event, data, internalCache.handle.elem );
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO: Stop taunting the data cache; remove global events and always attach to document
|
||||
jQuery.each( jQuery.cache, function() {
|
||||
// internalKey variable is just used to make it easier to find
|
||||
// and potentially change this stuff later; currently it just
|
||||
// points to jQuery.expando
|
||||
var internalKey = jQuery.expando,
|
||||
internalCache = this[ internalKey ];
|
||||
if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
|
||||
jQuery.event.trigger( event, data, internalCache.handle.elem );
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -346,7 +344,7 @@ jQuery.event = {
|
|||
event.target = elem;
|
||||
|
||||
// Clone any incoming data and prepend the event, creating the handler arg list
|
||||
data = data ? jQuery.makeArray( data ) : [];
|
||||
data = data != null ? jQuery.makeArray( data ) : [];
|
||||
data.unshift( event );
|
||||
|
||||
var cur = elem,
|
||||
|
@ -404,6 +402,8 @@ jQuery.event = {
|
|||
jQuery.event.triggered = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return event.result;
|
||||
},
|
||||
|
||||
handle: function( event ) {
|
||||
|
@ -650,33 +650,27 @@ jQuery.Event.prototype = {
|
|||
// Checks if an event happened on an element within another element
|
||||
// Used in jQuery.event.special.mouseenter and mouseleave handlers
|
||||
var withinElement = function( event ) {
|
||||
|
||||
// Check if mouse(over|out) are still within the same parent element
|
||||
var parent = event.relatedTarget;
|
||||
var related = event.relatedTarget,
|
||||
inside = false,
|
||||
eventType = event.type;
|
||||
|
||||
// Firefox sometimes assigns relatedTarget a XUL element
|
||||
// which we cannot access the parentNode property of
|
||||
try {
|
||||
event.type = event.data;
|
||||
|
||||
// Chrome does something similar, the parentNode property
|
||||
// can be accessed but is null.
|
||||
if ( parent && parent !== document && !parent.parentNode ) {
|
||||
return;
|
||||
}
|
||||
// Traverse up the tree
|
||||
while ( parent && parent !== this ) {
|
||||
parent = parent.parentNode;
|
||||
if ( related !== this ) {
|
||||
|
||||
if ( related ) {
|
||||
inside = jQuery.contains( this, related );
|
||||
}
|
||||
|
||||
if ( parent !== this ) {
|
||||
// set the correct event type
|
||||
event.type = event.data;
|
||||
if ( !inside ) {
|
||||
|
||||
// handle event if we actually just moused on to a non sub-element
|
||||
jQuery.event.handle.apply( this, arguments );
|
||||
}
|
||||
|
||||
// assuming we've left the element since we most likely mousedover a xul element
|
||||
} catch(e) { }
|
||||
event.type = eventType;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// In case of event delegation, we only need to rename the event.type,
|
||||
|
@ -706,7 +700,7 @@ if ( !jQuery.support.submitBubbles ) {
|
|||
|
||||
jQuery.event.special.submit = {
|
||||
setup: function( data, namespaces ) {
|
||||
if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
|
||||
if ( !jQuery.nodeName( this, "form" ) ) {
|
||||
jQuery.event.add(this, "click.specialSubmit", function( e ) {
|
||||
var elem = e.target,
|
||||
type = elem.type;
|
||||
|
@ -755,7 +749,7 @@ if ( !jQuery.support.changeBubbles ) {
|
|||
}).join("-") :
|
||||
"";
|
||||
|
||||
} else if ( elem.nodeName.toLowerCase() === "select" ) {
|
||||
} else if ( jQuery.nodeName( elem, "select" ) ) {
|
||||
val = elem.selectedIndex;
|
||||
}
|
||||
|
||||
|
@ -797,7 +791,7 @@ if ( !jQuery.support.changeBubbles ) {
|
|||
click: function( e ) {
|
||||
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
|
||||
|
||||
if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
|
||||
if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
|
||||
testChange.call( this, e );
|
||||
}
|
||||
},
|
||||
|
@ -807,7 +801,7 @@ if ( !jQuery.support.changeBubbles ) {
|
|||
keydown: function( e ) {
|
||||
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
|
||||
|
||||
if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
|
||||
if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
|
||||
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
|
||||
type === "select-multiple" ) {
|
||||
testChange.call( this, e );
|
||||
|
@ -909,7 +903,7 @@ jQuery.each(["bind", "one"], function( i, name ) {
|
|||
return this;
|
||||
}
|
||||
|
||||
if ( jQuery.isFunction( data ) || data === false ) {
|
||||
if ( arguments.length === 2 || data === false ) {
|
||||
fn = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
@ -975,11 +969,7 @@ jQuery.fn.extend({
|
|||
|
||||
triggerHandler: function( type, data ) {
|
||||
if ( this[0] ) {
|
||||
var event = new jQuery.Event( type );
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
jQuery.event.trigger( event, data, this[0] );
|
||||
return event.result;
|
||||
return jQuery.event.trigger( type, data, this[0], true );
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1066,7 +1056,7 @@ jQuery.each(["live", "die"], function( i, name ) {
|
|||
|
||||
preType = type;
|
||||
|
||||
if ( type === "focus" || type === "blur" ) {
|
||||
if ( liveMap[ type ] ) {
|
||||
types.push( liveMap[ type ] + namespaces );
|
||||
type = type + namespaces;
|
||||
|
||||
|
@ -1137,6 +1127,11 @@ function liveHandler( event ) {
|
|||
if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
|
||||
event.type = handleObj.preType;
|
||||
related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
|
||||
|
||||
// Make sure not to accidentally match a child element with the same selector
|
||||
if ( related && jQuery.contains( elem, related ) ) {
|
||||
related = elem;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !related || related !== elem ) {
|
||||
|
@ -1175,7 +1170,7 @@ function liveHandler( event ) {
|
|||
}
|
||||
|
||||
function liveConvert( type, selector ) {
|
||||
return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
|
||||
return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
|
||||
}
|
||||
|
||||
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
||||
|
|
|
@ -16,4 +16,6 @@
|
|||
(function( window, undefined ) {
|
||||
|
||||
// Use the correct document accordingly with window argument (sandbox)
|
||||
var document = window.document;
|
||||
var document = window.document,
|
||||
navigator = window.navigator,
|
||||
location = window.location;
|
||||
|
|
|
@ -10,6 +10,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
|
|||
// checked="checked" or checked
|
||||
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
||||
rscriptType = /\/(java|ecma)script/i,
|
||||
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
|
||||
wrapMap = {
|
||||
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
||||
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
||||
|
@ -70,7 +71,7 @@ jQuery.fn.extend({
|
|||
}
|
||||
|
||||
return elem;
|
||||
}).append(this);
|
||||
}).append( this );
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -379,13 +380,13 @@ function cloneCopyEvent( src, dest ) {
|
|||
}
|
||||
|
||||
function cloneFixAttributes( src, dest ) {
|
||||
var nodeName;
|
||||
|
||||
// We do not need to do anything for non-Elements
|
||||
if ( dest.nodeType !== 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nodeName = dest.nodeName.toLowerCase();
|
||||
|
||||
// clearAttributes removes the attributes, which we don't want,
|
||||
// but also removes the attachEvent events, which we *do* want
|
||||
if ( dest.clearAttributes ) {
|
||||
|
@ -398,6 +399,8 @@ function cloneFixAttributes( src, dest ) {
|
|||
dest.mergeAttributes( src );
|
||||
}
|
||||
|
||||
nodeName = dest.nodeName.toLowerCase();
|
||||
|
||||
// IE6-8 fail to clone children inside object elements that use
|
||||
// the proprietary classid attribute value (rather than the type
|
||||
// attribute) to identify the type of content to display
|
||||
|
@ -435,8 +438,21 @@ function cloneFixAttributes( src, dest ) {
|
|||
}
|
||||
|
||||
jQuery.buildFragment = function( args, nodes, scripts ) {
|
||||
var fragment, cacheable, cacheresults,
|
||||
doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
|
||||
var fragment, cacheable, cacheresults, doc;
|
||||
|
||||
// nodes may contain either an explicit document object,
|
||||
// a jQuery collection or context object.
|
||||
// If nodes[0] contains a valid object to assign to doc
|
||||
if ( nodes && nodes[0] ) {
|
||||
doc = nodes[0].ownerDocument || nodes[0];
|
||||
}
|
||||
|
||||
// Ensure that an attr object doesn't incorrectly stand in as a document object
|
||||
// Chrome and Firefox seem to allow this to occur and will throw exception
|
||||
// Fixes #8950
|
||||
if ( !doc.createDocumentFragment ) {
|
||||
doc = document;
|
||||
}
|
||||
|
||||
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
|
||||
// Cloning options loses the selected state, so don't cache them
|
||||
|
@ -446,11 +462,10 @@ jQuery.buildFragment = function( args, nodes, scripts ) {
|
|||
args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
|
||||
|
||||
cacheable = true;
|
||||
|
||||
cacheresults = jQuery.fragments[ args[0] ];
|
||||
if ( cacheresults ) {
|
||||
if ( cacheresults !== 1 ) {
|
||||
fragment = cacheresults;
|
||||
}
|
||||
if ( cacheresults && cacheresults !== 1 ) {
|
||||
fragment = cacheresults;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,7 +514,7 @@ jQuery.each({
|
|||
function getAll( elem ) {
|
||||
if ( "getElementsByTagName" in elem ) {
|
||||
return elem.getElementsByTagName( "*" );
|
||||
|
||||
|
||||
} else if ( "querySelectorAll" in elem ) {
|
||||
return elem.querySelectorAll( "*" );
|
||||
|
||||
|
@ -508,6 +523,21 @@ function getAll( elem ) {
|
|||
}
|
||||
}
|
||||
|
||||
// Used in clean, fixes the defaultChecked property
|
||||
function fixDefaultChecked( elem ) {
|
||||
if ( elem.type === "checkbox" || elem.type === "radio" ) {
|
||||
elem.defaultChecked = elem.checked;
|
||||
}
|
||||
}
|
||||
// Finds all inputs and passes them to fixDefaultChecked
|
||||
function findInputs( elem ) {
|
||||
if ( jQuery.nodeName( elem, "input" ) ) {
|
||||
fixDefaultChecked( elem );
|
||||
} else if ( "getElementsByTagName" in elem ) {
|
||||
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
|
||||
}
|
||||
}
|
||||
|
||||
jQuery.extend({
|
||||
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
||||
var clone = elem.cloneNode(true),
|
||||
|
@ -552,6 +582,8 @@ jQuery.extend({
|
|||
}
|
||||
}
|
||||
|
||||
srcElements = destElements = null;
|
||||
|
||||
// Return the cloned set
|
||||
return clone;
|
||||
},
|
||||
|
@ -566,7 +598,7 @@ jQuery.extend({
|
|||
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
|
||||
}
|
||||
|
||||
var ret = [];
|
||||
var ret = [], j;
|
||||
|
||||
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
||||
if ( typeof elem === "number" ) {
|
||||
|
@ -578,54 +610,67 @@ jQuery.extend({
|
|||
}
|
||||
|
||||
// Convert html string into DOM nodes
|
||||
if ( typeof elem === "string" && !rhtml.test( elem ) ) {
|
||||
elem = context.createTextNode( elem );
|
||||
if ( typeof elem === "string" ) {
|
||||
if ( !rhtml.test( elem ) ) {
|
||||
elem = context.createTextNode( elem );
|
||||
} else {
|
||||
// Fix "XHTML"-style tags in all browsers
|
||||
elem = elem.replace(rxhtmlTag, "<$1></$2>");
|
||||
|
||||
} else if ( typeof elem === "string" ) {
|
||||
// Fix "XHTML"-style tags in all browsers
|
||||
elem = elem.replace(rxhtmlTag, "<$1></$2>");
|
||||
// Trim whitespace, otherwise indexOf won't work as expected
|
||||
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
|
||||
wrap = wrapMap[ tag ] || wrapMap._default,
|
||||
depth = wrap[0],
|
||||
div = context.createElement("div");
|
||||
|
||||
// Trim whitespace, otherwise indexOf won't work as expected
|
||||
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
|
||||
wrap = wrapMap[ tag ] || wrapMap._default,
|
||||
depth = wrap[0],
|
||||
div = context.createElement("div");
|
||||
// Go to html and back, then peel off extra wrappers
|
||||
div.innerHTML = wrap[1] + elem + wrap[2];
|
||||
|
||||
// Go to html and back, then peel off extra wrappers
|
||||
div.innerHTML = wrap[1] + elem + wrap[2];
|
||||
// Move to the right depth
|
||||
while ( depth-- ) {
|
||||
div = div.lastChild;
|
||||
}
|
||||
|
||||
// Move to the right depth
|
||||
while ( depth-- ) {
|
||||
div = div.lastChild;
|
||||
}
|
||||
// Remove IE's autoinserted <tbody> from table fragments
|
||||
if ( !jQuery.support.tbody ) {
|
||||
|
||||
// Remove IE's autoinserted <tbody> from table fragments
|
||||
if ( !jQuery.support.tbody ) {
|
||||
// String was a <table>, *may* have spurious <tbody>
|
||||
var hasBody = rtbody.test(elem),
|
||||
tbody = tag === "table" && !hasBody ?
|
||||
div.firstChild && div.firstChild.childNodes :
|
||||
|
||||
// String was a <table>, *may* have spurious <tbody>
|
||||
var hasBody = rtbody.test(elem),
|
||||
tbody = tag === "table" && !hasBody ?
|
||||
div.firstChild && div.firstChild.childNodes :
|
||||
// String was a bare <thead> or <tfoot>
|
||||
wrap[1] === "<table>" && !hasBody ?
|
||||
div.childNodes :
|
||||
[];
|
||||
|
||||
// String was a bare <thead> or <tfoot>
|
||||
wrap[1] === "<table>" && !hasBody ?
|
||||
div.childNodes :
|
||||
[];
|
||||
|
||||
for ( var j = tbody.length - 1; j >= 0 ; --j ) {
|
||||
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
|
||||
tbody[ j ].parentNode.removeChild( tbody[ j ] );
|
||||
for ( j = tbody.length - 1; j >= 0 ; --j ) {
|
||||
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
|
||||
tbody[ j ].parentNode.removeChild( tbody[ j ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// IE completely kills leading whitespace when innerHTML is used
|
||||
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
||||
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
|
||||
}
|
||||
|
||||
// IE completely kills leading whitespace when innerHTML is used
|
||||
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
||||
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
|
||||
elem = div.childNodes;
|
||||
}
|
||||
}
|
||||
|
||||
elem = div.childNodes;
|
||||
// Resets defaultChecked for any radios and checkboxes
|
||||
// about to be appended to the DOM in IE 6/7 (#8060)
|
||||
var len;
|
||||
if ( !jQuery.support.appendChecked ) {
|
||||
if ( elem[0] && typeof (len = elem.length) === "number" ) {
|
||||
for ( j = 0; j < len; j++ ) {
|
||||
findInputs( elem[j] );
|
||||
}
|
||||
} else {
|
||||
findInputs( elem );
|
||||
}
|
||||
}
|
||||
|
||||
if ( elem.nodeType ) {
|
||||
|
@ -709,7 +754,7 @@ function evalScript( i, elem ) {
|
|||
dataType: "script"
|
||||
});
|
||||
} else {
|
||||
jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
|
||||
jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
|
||||
}
|
||||
|
||||
if ( elem.parentNode ) {
|
||||
|
@ -717,4 +762,4 @@ function evalScript( i, elem ) {
|
|||
}
|
||||
}
|
||||
|
||||
})( jQuery );
|
||||
})( jQuery );
|
|
@ -1,2 +1,3 @@
|
|||
// Expose jQuery to the global object
|
||||
window.jQuery = window.$ = jQuery;
|
||||
})(window);
|
||||
|
|
|
@ -148,7 +148,8 @@ jQuery.fn.extend({
|
|||
count = 1,
|
||||
deferDataKey = type + "defer",
|
||||
queueDataKey = type + "queue",
|
||||
markDataKey = type + "mark";
|
||||
markDataKey = type + "mark",
|
||||
tmp;
|
||||
function resolve() {
|
||||
if ( !( --count ) ) {
|
||||
defer.resolveWith( elements, [ elements ] );
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 69ecd019852c1421cbd81fe6ceb4e22a81022ea7
|
||||
Subproject commit 3ba396e439a07c2a2facafbe07cdaa1b80a24c00
|
|
@ -3,6 +3,7 @@
|
|||
jQuery.support = (function() {
|
||||
|
||||
var div = document.createElement( "div" ),
|
||||
documentElement = document.documentElement,
|
||||
all,
|
||||
a,
|
||||
select,
|
||||
|
@ -12,7 +13,9 @@ jQuery.support = (function() {
|
|||
support,
|
||||
fragment,
|
||||
body,
|
||||
bodyStyle,
|
||||
testElementParent,
|
||||
testElement,
|
||||
testElementStyle,
|
||||
tds,
|
||||
events,
|
||||
eventName,
|
||||
|
@ -77,10 +80,6 @@ jQuery.support = (function() {
|
|||
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
||||
getSetAttribute: div.className !== "t",
|
||||
|
||||
// Test for presence of native Function#bind.
|
||||
// Not in: >= Chrome 6, >= FireFox 3, Safari 5?, IE 9?, Opera 11?
|
||||
nativeBind: jQuery.isFunction( Function.prototype.bind ),
|
||||
|
||||
// Will be defined later
|
||||
submitBubbles: true,
|
||||
changeBubbles: true,
|
||||
|
@ -110,17 +109,23 @@ jQuery.support = (function() {
|
|||
}
|
||||
|
||||
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
|
||||
div.attachEvent( "onclick", function click() {
|
||||
div.attachEvent( "onclick", function() {
|
||||
// Cloning a node shouldn't copy over any
|
||||
// bound event handlers (IE does this)
|
||||
support.noCloneEvent = false;
|
||||
div.detachEvent( "onclick", click );
|
||||
});
|
||||
div.cloneNode( true ).fireEvent( "onclick" );
|
||||
}
|
||||
|
||||
div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
|
||||
// Check if a radio maintains it's value
|
||||
// after being appended to the DOM
|
||||
input = document.createElement("input");
|
||||
input.value = "t";
|
||||
input.setAttribute("type", "radio");
|
||||
support.radioValue = input.value === "t";
|
||||
|
||||
input.setAttribute("checked", "checked");
|
||||
div.appendChild( input );
|
||||
fragment = document.createDocumentFragment();
|
||||
fragment.appendChild( div.firstChild );
|
||||
|
||||
|
@ -132,20 +137,34 @@ jQuery.support = (function() {
|
|||
// Figure out if the W3C box model works as expected
|
||||
div.style.width = div.style.paddingLeft = "1px";
|
||||
|
||||
// We use our own, invisible, body
|
||||
body = document.createElement( "body" );
|
||||
bodyStyle = {
|
||||
body = document.getElementsByTagName( "body" )[ 0 ];
|
||||
// We use our own, invisible, body unless the body is already present
|
||||
// in which case we use a div (#9239)
|
||||
testElement = document.createElement( body ? "div" : "body" );
|
||||
testElementStyle = {
|
||||
visibility: "hidden",
|
||||
width: 0,
|
||||
height: 0,
|
||||
border: 0,
|
||||
margin: 0
|
||||
};
|
||||
for ( i in bodyStyle ) {
|
||||
body.style[ i ] = bodyStyle[ i ];
|
||||
if ( body ) {
|
||||
jQuery.extend( testElementStyle, {
|
||||
position: "absolute",
|
||||
left: -1000,
|
||||
top: -1000
|
||||
});
|
||||
}
|
||||
body.appendChild( div );
|
||||
document.documentElement.appendChild( body );
|
||||
for ( i in testElementStyle ) {
|
||||
testElement.style[ i ] = testElementStyle[ i ];
|
||||
}
|
||||
testElement.appendChild( div );
|
||||
testElementParent = body || documentElement;
|
||||
testElementParent.insertBefore( testElement, testElementParent.firstChild );
|
||||
|
||||
// Check if a disconnected checkbox will retain its checked
|
||||
// value of true after appended to the DOM (IE6/7)
|
||||
support.appendChecked = input.checked;
|
||||
|
||||
support.boxModel = div.offsetWidth === 2;
|
||||
|
||||
|
@ -191,16 +210,17 @@ jQuery.support = (function() {
|
|||
// Fails in WebKit before Feb 2011 nightlies
|
||||
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
||||
if ( document.defaultView && document.defaultView.getComputedStyle ) {
|
||||
marginDiv = document.createElement('div');
|
||||
marginDiv = document.createElement( "div" );
|
||||
marginDiv.style.width = "0";
|
||||
marginDiv.style.marginRight = "0";
|
||||
div.appendChild( marginDiv );
|
||||
support.reliableMarginRight =
|
||||
( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0;
|
||||
( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
|
||||
}
|
||||
|
||||
// Remove the body element we added
|
||||
document.documentElement.removeChild( body );
|
||||
testElement.innerHTML = "";
|
||||
testElementParent.removeChild( testElement );
|
||||
|
||||
// Technique from Juriy Zaytsev
|
||||
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
||||
|
@ -224,6 +244,9 @@ jQuery.support = (function() {
|
|||
}
|
||||
}
|
||||
|
||||
// Null connected elements to avoid leaks in IE
|
||||
testElement = fragment = select = opt = body = marginDiv = div = input = null;
|
||||
|
||||
return support;
|
||||
})();
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ jQuery.fn.extend({
|
|||
add: function( selector, context ) {
|
||||
var set = typeof selector === "string" ?
|
||||
jQuery( selector, context ) :
|
||||
jQuery.makeArray( selector ),
|
||||
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
|
||||
all = jQuery.merge( this.get(), set );
|
||||
|
||||
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<dashboard>
|
||||
<locations class="foo">
|
||||
<location for="bar">
|
||||
<location for="bar" checked="different">
|
||||
<infowindowtab>
|
||||
<tab title="Location"><![CDATA[blabla]]></tab>
|
||||
<tab title="Users"><![CDATA[blublu]]></tab>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<!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" dir="ltr" id="html">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
body {
|
||||
background: #000000;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<script src="../../../src/core.js"></script>
|
||||
<script src="../../../src/deferred.js"></script>
|
||||
<script src="../../../src/support.js"></script>
|
||||
<script src="../../../src/data.js"></script>
|
||||
<script src="../../../src/queue.js"></script>
|
||||
<script src="../../../src/attributes.js"></script>
|
||||
<script src="../../../src/event.js"></script>
|
||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||
<script src="../../../src/sizzle-jquery.js"></script>
|
||||
<script src="../../../src/traversing.js"></script>
|
||||
<script src="../../../src/manipulation.js"></script>
|
||||
<script src="../../../src/css.js"></script>
|
||||
<script src="../../../src/ajax.js"></script>
|
||||
<script src="../../../src/ajax/jsonp.js"></script>
|
||||
<script src="../../../src/ajax/script.js"></script>
|
||||
<script src="../../../src/ajax/xhr.js"></script>
|
||||
<script src="../../../src/effects.js"></script>
|
||||
<script src="../../../src/offset.js"></script>
|
||||
<script src="../../../src/dimensions.js"></script>
|
||||
</div>
|
||||
<script>
|
||||
window.top.supportCallback( jQuery( "body" ).css( "backgroundColor" ), jQuery.support );
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<body>
|
||||
<script src="../../../src/core.js"></script>
|
||||
<script src="../../../src/deferred.js"></script>
|
||||
<script src="../../../src/support.js"></script>
|
||||
<script src="../../../src/data.js"></script>
|
||||
<script src="../../../src/queue.js"></script>
|
||||
<script src="../../../src/attributes.js"></script>
|
||||
<script src="../../../src/event.js"></script>
|
||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||
<script src="../../../src/sizzle-jquery.js"></script>
|
||||
<script src="../../../src/traversing.js"></script>
|
||||
<script src="../../../src/manipulation.js"></script>
|
||||
<script src="../../../src/css.js"></script>
|
||||
<script src="../../../src/ajax.js"></script>
|
||||
<script src="../../../src/ajax/jsonp.js"></script>
|
||||
<script src="../../../src/ajax/script.js"></script>
|
||||
<script src="../../../src/ajax/xhr.js"></script>
|
||||
<script src="../../../src/effects.js"></script>
|
||||
<script src="../../../src/offset.js"></script>
|
||||
<script src="../../../src/dimensions.js"></script>
|
||||
<script>
|
||||
window.top.supportCallback( document.compatMode, jQuery.support.boxModel );
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="../../../src/core.js"></script>
|
||||
<script src="../../../src/deferred.js"></script>
|
||||
<script src="../../../src/support.js"></script>
|
||||
<script src="../../../src/data.js"></script>
|
||||
<script src="../../../src/queue.js"></script>
|
||||
<script src="../../../src/attributes.js"></script>
|
||||
<script src="../../../src/event.js"></script>
|
||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||
<script src="../../../src/sizzle-jquery.js"></script>
|
||||
<script src="../../../src/traversing.js"></script>
|
||||
<script src="../../../src/manipulation.js"></script>
|
||||
<script src="../../../src/css.js"></script>
|
||||
<script src="../../../src/ajax.js"></script>
|
||||
<script src="../../../src/ajax/jsonp.js"></script>
|
||||
<script src="../../../src/ajax/script.js"></script>
|
||||
<script src="../../../src/ajax/xhr.js"></script>
|
||||
<script src="../../../src/effects.js"></script>
|
||||
<script src="../../../src/offset.js"></script>
|
||||
<script src="../../../src/dimensions.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -2,8 +2,9 @@ jQuery.noConflict(); // Allow the test to run with other libs or jQuery's.
|
|||
|
||||
// jQuery-specific QUnit.reset
|
||||
(function() {
|
||||
var reset = QUnit.reset;
|
||||
var ajaxSettings = jQuery.ajaxSettings
|
||||
var reset = QUnit.reset,
|
||||
ajaxSettings = jQuery.ajaxSettings;
|
||||
|
||||
QUnit.reset = function() {
|
||||
reset.apply(this, arguments);
|
||||
jQuery.event.global = {};
|
||||
|
@ -24,3 +25,9 @@ jQuery.noConflict(); // Allow the test to run with other libs or jQuery's.
|
|||
|
||||
document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
|
||||
})();
|
||||
|
||||
// QUnit Aliases
|
||||
(function() {
|
||||
window.equals = window.equal;
|
||||
window.same = window.deepEqual;
|
||||
})();
|
||||
|
|
|
@ -117,3 +117,7 @@ v\:oval { behavior:url(#default#VML); display:inline-block; }
|
|||
tt { display: none; }
|
||||
sup { display: none; }
|
||||
dfn { display: none; }
|
||||
|
||||
/* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */
|
||||
body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif) no-repeat -1000px 0; }
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// Run minified source from dist (do make first)
|
||||
// Should be loaded before QUnit but after src
|
||||
(function() {
|
||||
if ( /jquery\=min/.test( window.location.search ) ) {
|
||||
jQuery.noConflict( true );
|
||||
document.write(unescape("%3Cscript%20src%3D%27../dist/jquery.min.js%27%3E%3C/script%3E"));
|
||||
}
|
||||
})();
|
|
@ -183,10 +183,20 @@
|
|||
<td id='boundSubmit' class="red">DOCUMENT</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h1>Mouseleave Tests</h1>
|
||||
|
||||
<div class="out" style="margin:20px; border:1px solid #000; background: red;">
|
||||
<p>Count mouse leave event</p>
|
||||
<div class="in" style="background: green; margin: 10px auto; width: 50%;">
|
||||
<p>mouse over here should not trigger the counter.</p>
|
||||
</div>
|
||||
<p>0</p>
|
||||
</div>
|
||||
|
||||
<ul id="log"></ul>
|
||||
|
||||
<script type='text/javascript'>
|
||||
<script type='text/javascript'>
|
||||
jQuery.fn.addChangeClickTest = function( id, prevent ) {
|
||||
this.bind("focusin", function(){
|
||||
jQuery(id + "focus").blink();
|
||||
|
@ -270,6 +280,10 @@
|
|||
jQuery("#boundSubmit").blink();
|
||||
});
|
||||
|
||||
</script>
|
||||
var n = 0;
|
||||
$("div.out").live("mouseleave", function() {
|
||||
$("p:last", this).text(++n);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -28,10 +28,13 @@
|
|||
<script src="../src/offset.js"></script>
|
||||
<script src="../src/dimensions.js"></script>
|
||||
|
||||
<script src="data/versioncheck.js"></script>
|
||||
|
||||
<script src="qunit/qunit/qunit.js"></script>
|
||||
<script src="data/testrunner.js"></script>
|
||||
|
||||
<script src="unit/core.js"></script>
|
||||
<script src="unit/support.js"></script>
|
||||
<script src="unit/deferred.js"></script>
|
||||
<script src="unit/data.js"></script>
|
||||
<script src="unit/queue.js"></script>
|
||||
|
@ -48,7 +51,9 @@
|
|||
</head>
|
||||
|
||||
<body id="body">
|
||||
<h1 id="qunit-header">jQuery Test Suite</h1>
|
||||
<h1 id="qunit-header"><a href="/jquery/test/index.html">jQuery Test Suite</a>
|
||||
<a href="?jquery=min">(minified)</a>
|
||||
</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
|
@ -58,10 +63,10 @@
|
|||
<div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv">
|
||||
<div id="nothiddendivchild"></div>
|
||||
</div>
|
||||
<!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
|
||||
<!-- this iframe is outside the #qunit-fixture so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
|
||||
<iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe>
|
||||
<dl id="dl" style="position:absolute;top:-32767px;left:-32767px;">
|
||||
<div id="main">
|
||||
<dl id="dl" style="position:absolute;top:-32767px;left:-32767px;width:1px">
|
||||
<div id="qunit-fixture">
|
||||
<p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
|
||||
<p id="ap">
|
||||
Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d404faf8f587fcbe6b8907943022e6318dd51e0c
|
||||
Subproject commit d4f23f8a882d13b71768503e2db9fa33ef169ba0
|
|
@ -321,25 +321,40 @@ test("jQuery.ajax() - responseText on error", function() {
|
|||
|
||||
test(".ajax() - retry with jQuery.ajax( this )", function() {
|
||||
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
|
||||
stop();
|
||||
|
||||
var firstTime = 1;
|
||||
var firstTime = true,
|
||||
previousUrl;
|
||||
|
||||
jQuery.ajax({
|
||||
url: url("data/errorWithText.php"),
|
||||
error: function() {
|
||||
if ( firstTime ) {
|
||||
firstTime = 0;
|
||||
firstTime = false;
|
||||
jQuery.ajax( this );
|
||||
} else {
|
||||
ok( true , "Test retrying with jQuery.ajax(this) works" );
|
||||
start();
|
||||
jQuery.ajax({
|
||||
url: url("data/errorWithText.php"),
|
||||
data: { x: 1 },
|
||||
beforeSend: function() {
|
||||
if ( !previousUrl ) {
|
||||
previousUrl = this.url;
|
||||
} else {
|
||||
strictEqual( this.url , previousUrl, "url parameters are not re-appended" );
|
||||
start();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
jQuery.ajax( this );
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test(".ajax() - headers" , function() {
|
||||
|
@ -946,7 +961,7 @@ test("serialize()", function() {
|
|||
});
|
||||
|
||||
test("jQuery.param()", function() {
|
||||
expect(24);
|
||||
expect(21);
|
||||
|
||||
equals( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" );
|
||||
|
||||
|
@ -976,11 +991,6 @@ test("jQuery.param()", function() {
|
|||
|
||||
equals( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
|
||||
// Make sure empty arrays and objects are handled #6481
|
||||
equals( jQuery.param({"foo": {"bar": []} }), "foo%5Bbar%5D=", "Empty array param" );
|
||||
equals( jQuery.param({"foo": {"bar": [], foo: 1} }), "foo%5Bbar%5D=&foo%5Bfoo%5D=1", "Empty array param" );
|
||||
equals( jQuery.param({"foo": {"bar": {}} }), "foo%5Bbar%5D=", "Empty object param" );
|
||||
|
||||
// #7945
|
||||
equals( jQuery.param({"jquery": "1.4.2"}), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" );
|
||||
|
||||
|
@ -1787,7 +1797,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
|||
passed++;
|
||||
if ( passed == 2 ) {
|
||||
ok( true, "Check local and global callbacks after timeout" );
|
||||
jQuery("#main").unbind("ajaxError");
|
||||
jQuery("#qunit-fixture").unbind("ajaxError");
|
||||
start();
|
||||
}
|
||||
};
|
||||
|
@ -1797,7 +1807,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
|||
start();
|
||||
};
|
||||
|
||||
jQuery("#main").ajaxError(pass);
|
||||
jQuery("#qunit-fixture").ajaxError(pass);
|
||||
|
||||
jQuery.ajax({
|
||||
type: "GET",
|
||||
|
@ -2259,4 +2269,4 @@ test("jQuery.ajax - active counter", function() {
|
|||
|
||||
}
|
||||
|
||||
//}
|
||||
//}
|
||||
|
|
|
@ -4,79 +4,43 @@ var bareObj = function(value) { return value; };
|
|||
var functionReturningObj = function(value) { return (function() { return value; }); };
|
||||
|
||||
|
||||
test("jQuery.attrFix integrity test", function() {
|
||||
expect(1);
|
||||
test("jQuery.attrFix/jQuery.propFix integrity test", function() {
|
||||
expect(2);
|
||||
|
||||
// This must be maintained and equal jQuery.attrFix when appropriate
|
||||
// Ensure that accidental or erroneous property
|
||||
// overwrites don't occur
|
||||
// This is simply for better code coverage and future proofing.
|
||||
var propsShouldBe;
|
||||
if ( !jQuery.support.getSetAttribute ) {
|
||||
propsShouldBe = {
|
||||
var props = {
|
||||
tabindex: "tabIndex",
|
||||
readonly: "readOnly",
|
||||
"for": "htmlFor",
|
||||
"class": "className",
|
||||
maxlength: "maxLength",
|
||||
cellspacing: "cellSpacing",
|
||||
cellpadding: "cellPadding",
|
||||
rowspan: "rowSpan",
|
||||
colspan: "colSpan",
|
||||
usemap: "useMap",
|
||||
frameborder: "frameBorder"
|
||||
};
|
||||
frameborder: "frameBorder",
|
||||
contenteditable: "contentEditable"
|
||||
},
|
||||
propsShouldBe;
|
||||
|
||||
if ( !jQuery.support.getSetAttribute ) {
|
||||
propsShouldBe = props;
|
||||
} else {
|
||||
propsShouldBe = {
|
||||
tabindex: "tabIndex",
|
||||
readonly: "readOnly"
|
||||
tabindex: "tabIndex"
|
||||
};
|
||||
}
|
||||
|
||||
same(propsShouldBe, jQuery.attrFix, "jQuery.attrFix passes integrity check");
|
||||
});
|
||||
|
||||
test("prop(String, Object)", function() {
|
||||
expect(19);
|
||||
equals( jQuery("#text1").prop("value"), "Test", "Check for value attribute" );
|
||||
equals( jQuery("#text1").prop("value", "Test2").prop("defaultValue"), "Test", "Check for defaultValue attribute" );
|
||||
equals( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" );
|
||||
equals( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" );
|
||||
equals( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" );
|
||||
equals( jQuery("<option/>").prop("selected"), false, "Check selected attribute on disconnected element." );
|
||||
|
||||
var body = document.body, $body = jQuery( body );
|
||||
ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
|
||||
body.foo = "bar";
|
||||
equals( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
|
||||
body.foo = undefined;
|
||||
ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
|
||||
|
||||
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
|
||||
optgroup.appendChild( option );
|
||||
select.appendChild( optgroup );
|
||||
|
||||
equals( jQuery(option).prop("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
|
||||
equals( jQuery(document).prop("nodeName"), "#document", "prop works correctly on document nodes (bug #7451)." );
|
||||
|
||||
var attributeNode = document.createAttribute("irrelevant"),
|
||||
commentNode = document.createComment("some comment"),
|
||||
textNode = document.createTextNode("some text"),
|
||||
obj = {};
|
||||
jQuery.each( [document, attributeNode, commentNode, textNode, obj, "#firstp"], function( i, ele ) {
|
||||
strictEqual( jQuery(ele).prop("nonexisting"), undefined, "prop works correctly for non existing attributes (bug #7500)." );
|
||||
});
|
||||
|
||||
var obj = {};
|
||||
jQuery.each( [document, obj], function( i, ele ) {
|
||||
var $ele = jQuery( ele );
|
||||
$ele.prop( "nonexisting", "foo" );
|
||||
equal( $ele.prop("nonexisting"), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." );
|
||||
});
|
||||
jQuery( document ).removeProp("nonexisting");
|
||||
deepEqual(propsShouldBe, jQuery.attrFix, "jQuery.attrFix passes integrity check");
|
||||
deepEqual(props, jQuery.propFix, "jQuery.propFix passes integrity check");
|
||||
});
|
||||
|
||||
test("attr(String)", function() {
|
||||
expect(32);
|
||||
expect(45);
|
||||
|
||||
equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
|
||||
equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
|
||||
|
@ -89,6 +53,8 @@ test("attr(String)", function() {
|
|||
equals( jQuery("#name").attr("name"), "name", "Check for name attribute" );
|
||||
equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" );
|
||||
ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" );
|
||||
equals( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" );
|
||||
equals( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
|
||||
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
|
||||
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
|
||||
|
||||
|
@ -107,7 +73,7 @@ test("attr(String)", function() {
|
|||
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
|
||||
|
||||
// using innerHTML in IE causes href attribute to be serialized to the full path
|
||||
jQuery("<a/>").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#main");
|
||||
jQuery("<a/>").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#qunit-fixture");
|
||||
equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" );
|
||||
|
||||
// list attribute is readonly by default in browsers that support it
|
||||
|
@ -127,6 +93,12 @@ test("attr(String)", function() {
|
|||
|
||||
body.removeAttribute("foo"); // Cleanup
|
||||
|
||||
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
|
||||
optgroup.appendChild( option );
|
||||
select.appendChild( optgroup );
|
||||
|
||||
equal( jQuery( option ).attr("selected"), "selected", "Make sure that a single option is selected, even when in an optgroup." );
|
||||
|
||||
var $img = jQuery("<img style='display:none' width='215' height='53' src='http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif'/>").appendTo("body");
|
||||
equals( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." );
|
||||
equals( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." );
|
||||
|
@ -135,17 +107,37 @@ test("attr(String)", function() {
|
|||
ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" );
|
||||
ok( !!~jQuery("#foo").attr("style", "position:absolute;").attr("style").indexOf("position"), "Check style setter" );
|
||||
|
||||
// Check value on button element (#1954)
|
||||
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
|
||||
equals( $button.attr("value"), "foobar", "Value retrieval on a button does not return innerHTML" );
|
||||
equals( $button.attr("value", "baz").html(), "text", "Setting the value does not change innerHTML" );
|
||||
|
||||
// Attributes with a colon on a table element (#1591)
|
||||
equals( jQuery("#table").attr("test:attrib"), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." );
|
||||
equals( jQuery("#table").attr("test:attrib", "foobar").attr("test:attrib"), "foobar", "Setting an attribute on a table with a colon does not throw an error." );
|
||||
|
||||
var $form = jQuery("<form class='something'></form>").appendTo("#qunit-fixture");
|
||||
equal( $form.attr("class"), "something", "Retrieve the class attribute on a form." );
|
||||
|
||||
var $a = jQuery("<a href='#' onclick='something()'>Click</a>").appendTo("#qunit-fixture");
|
||||
equal( $a.attr("onclick"), "something()", "Retrieve ^on attribute without anonymous function wrapper." );
|
||||
|
||||
ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
|
||||
ok( jQuery("<div/>").attr("title") === undefined, "Make sure undefined is returned when no attribute is found." );
|
||||
equal( jQuery("<div/>").attr("title", "something").attr("title"), "something", "Set the title attribute." );
|
||||
ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
|
||||
equal( jQuery("<div/>").attr("value"), undefined, "An unset value on a div returns undefined." );
|
||||
equal( jQuery("<input/>").attr("value"), "", "An unset value on an input returns current value." );
|
||||
});
|
||||
|
||||
if ( !isLocal ) {
|
||||
test("attr(String) in XML Files", function() {
|
||||
expect(2);
|
||||
expect(3);
|
||||
stop();
|
||||
jQuery.get("data/dashboard.xml", function(xml) {
|
||||
equals( jQuery("locations", xml).attr("class"), "foo", "Check class attribute in XML document" );
|
||||
equals( jQuery("location", xml).attr("for"), "bar", "Check for attribute in XML document" );
|
||||
jQuery.get("data/dashboard.xml", function( xml ) {
|
||||
equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
|
||||
equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
|
||||
equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached in XML document" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -164,13 +156,13 @@ test("attr(Hash)", function() {
|
|||
if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) pass = false;
|
||||
});
|
||||
ok( pass, "Set Multiple Attributes" );
|
||||
equals( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
|
||||
equals( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
|
||||
equals( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
|
||||
equals( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
|
||||
|
||||
});
|
||||
|
||||
test("attr(String, Object)", function() {
|
||||
expect(29);
|
||||
expect(69);
|
||||
|
||||
var div = jQuery("div").attr("foo", "bar"),
|
||||
fail = false;
|
||||
|
@ -182,39 +174,92 @@ test("attr(String, Object)", function() {
|
|||
}
|
||||
}
|
||||
|
||||
equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" );
|
||||
equals( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" );
|
||||
|
||||
// Fails on IE since recent changes to .attr()
|
||||
// ok( jQuery("#foo").attr({"width": null}), "Try to set an attribute to nothing" );
|
||||
ok( jQuery("#foo").attr({ "width": null }), "Try to set an attribute to nothing" );
|
||||
|
||||
jQuery("#name").attr("name", "something");
|
||||
equals( jQuery("#name").attr("name"), "something", "Set name attribute" );
|
||||
jQuery("#name").attr("name", null);
|
||||
equals( jQuery("#name").attr("name"), undefined, "Remove name attribute" );
|
||||
jQuery("#check2").attr("checked", true);
|
||||
var $input = jQuery("<input>", { name: "something" });
|
||||
equals( $input.attr("name"), "something", "Check element creation gets/sets the name attribute." );
|
||||
|
||||
jQuery("#check2").prop("checked", true).prop("checked", false).attr("checked", true);
|
||||
equals( document.getElementById("check2").checked, true, "Set checked attribute" );
|
||||
equals( jQuery("#check2").prop("checked"), true, "Set checked attribute" );
|
||||
equals( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" );
|
||||
jQuery("#check2").attr("checked", false);
|
||||
equals( document.getElementById("check2").checked, false, "Set checked attribute" );
|
||||
equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" );
|
||||
equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" );
|
||||
jQuery("#text1").attr("readonly", true);
|
||||
equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" );
|
||||
jQuery("#text1").attr("readonly", false);
|
||||
equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" );
|
||||
|
||||
jQuery("#check2").prop("checked", true);
|
||||
equals( document.getElementById("check2").checked, true, "Set checked attribute" );
|
||||
equals( jQuery("#check2").prop("checked"), true, "Set checked attribute" );
|
||||
equals( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" );
|
||||
jQuery("#check2").prop("checked", false);
|
||||
equals( document.getElementById("check2").checked, false, "Set checked attribute" );
|
||||
equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" );
|
||||
equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" );
|
||||
|
||||
jQuery("#check2").attr("checked", "checked");
|
||||
equal( document.getElementById("check2").checked, true, "Set checked attribute with 'checked'" );
|
||||
equal( jQuery("#check2").prop("checked"), true, "Set checked attribute" );
|
||||
equal( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" );
|
||||
|
||||
jQuery("#text1").prop("readOnly", true);
|
||||
equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" );
|
||||
jQuery("#text1").prop("readOnly", false);
|
||||
equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" );
|
||||
equals( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" );
|
||||
|
||||
jQuery("#name").attr("maxlength", "5");
|
||||
equals( document.getElementById("name").maxLength, 5, "Set maxlength attribute" );
|
||||
jQuery("#name").attr("maxLength", "10");
|
||||
equals( document.getElementById("name").maxLength, 10, "Set maxlength attribute" );
|
||||
var $p = jQuery("#firstp").attr("nonexisting", "foo");
|
||||
equals( $p.attr("nonexisting"), "foo", "attr(name, value) works correctly for non existing attributes (bug #7500).");
|
||||
$p.removeAttr("nonexisting");
|
||||
|
||||
|
||||
var $text = jQuery("#text1").attr("autofocus", true);
|
||||
if ( "autofocus" in $text[0] ) {
|
||||
equals( $text.attr("autofocus"), "autofocus", "Set boolean attributes to the same name");
|
||||
} else {
|
||||
equals( $text.attr("autofocus"), undefined, "autofocus stays undefined in browsers that do not support it(F<4)");
|
||||
}
|
||||
equals( $text.attr("autofocus", false).attr("autofocus"), undefined, "Setting autofocus attribute to false removes it");
|
||||
equals( $text.attr("data-something", true).data("something"), true, "Setting data attributes are not affected by boolean settings");
|
||||
equals( $text.attr("data-another", false).data("another"), false, "Setting data attributes are not affected by boolean settings" );
|
||||
equals( $text.attr("aria-disabled", false).attr("aria-disabled"), "false", "Setting aria attributes are not affected by boolean settings");
|
||||
$text.removeData("something").removeData("another").removeAttr("aria-disabled");
|
||||
|
||||
jQuery("#foo").attr("contenteditable", true);
|
||||
equals( jQuery("#foo").attr("contenteditable"), "true", "Enumerated attributes are set properly" );
|
||||
|
||||
var attributeNode = document.createAttribute("irrelevant"),
|
||||
commentNode = document.createComment("some comment"),
|
||||
textNode = document.createTextNode("some text");
|
||||
textNode = document.createTextNode("some text"),
|
||||
obj = {};
|
||||
|
||||
jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) {
|
||||
var $ele = jQuery( ele );
|
||||
$ele.attr( "nonexisting", "foo" );
|
||||
strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
|
||||
jQuery.each( [commentNode, textNode, attributeNode], function( i, elem ) {
|
||||
var $elem = jQuery( elem );
|
||||
$elem.attr( "nonexisting", "foo" );
|
||||
strictEqual( $elem.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
|
||||
});
|
||||
|
||||
jQuery.each( [window, document, obj, "#firstp"], function( i, elem ) {
|
||||
var $elem = jQuery( elem );
|
||||
strictEqual( $elem.attr("nonexisting"), undefined, "attr works correctly for non existing attributes (bug #7500)." );
|
||||
equal( $elem.attr("something", "foo" ).attr("something"), "foo", "attr falls back to prop on unsupported arguments" );
|
||||
});
|
||||
|
||||
var table = jQuery("#table").append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
|
||||
|
@ -226,6 +271,8 @@ test("attr(String, Object)", function() {
|
|||
table.attr("cellspacing", "2");
|
||||
equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" );
|
||||
|
||||
equals( jQuery("#area1").attr("value"), "foobar", "Value attribute retrieves the property for backwards compatibility." );
|
||||
|
||||
// for #1070
|
||||
jQuery("#name").attr("someAttr", "0");
|
||||
equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" );
|
||||
|
@ -283,7 +330,10 @@ test("attr(String, Object)", function() {
|
|||
}
|
||||
ok( thrown, "Exception thrown when trying to change type property" );
|
||||
equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" );
|
||||
|
||||
|
||||
var $radio = jQuery("<input>", { "value": "sup", "type": "radio" }).appendTo("#testForm");
|
||||
equals( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" );
|
||||
|
||||
// Setting attributes on svg elements (bug #3116)
|
||||
var $svg = jQuery("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>"
|
||||
+ "<circle cx='200' cy='200' r='150' />"
|
||||
|
@ -327,10 +377,10 @@ if ( !isLocal ) {
|
|||
test("attr(String, Object) - Loaded via XML document", function() {
|
||||
expect(2);
|
||||
stop();
|
||||
jQuery.get("data/dashboard.xml", function(xml) {
|
||||
jQuery.get("data/dashboard.xml", function( xml ) {
|
||||
var titles = [];
|
||||
jQuery("tab", xml).each(function() {
|
||||
titles.push(jQuery(this).attr("title"));
|
||||
jQuery( "tab", xml ).each(function() {
|
||||
titles.push( jQuery(this).attr("title") );
|
||||
});
|
||||
equals( titles[0], "Location", "attr() in XML context: Check first title" );
|
||||
equals( titles[1], "Users", "attr() in XML context: Check second title" );
|
||||
|
@ -395,12 +445,79 @@ test("attr('tabindex', value)", function() {
|
|||
});
|
||||
|
||||
test("removeAttr(String)", function() {
|
||||
expect(5);
|
||||
expect(7);
|
||||
equals( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" );
|
||||
equals( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
|
||||
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
|
||||
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
|
||||
equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
|
||||
|
||||
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
|
||||
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
|
||||
jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
|
||||
equals( document.getElementById("text1").readOnly, false, "removeAttr sets boolean properties to false" );
|
||||
});
|
||||
|
||||
test("prop(String, Object)", function() {
|
||||
expect(30);
|
||||
|
||||
equals( jQuery("#text1").prop("value"), "Test", "Check for value attribute" );
|
||||
equals( jQuery("#text1").prop("value", "Test2").prop("defaultValue"), "Test", "Check for defaultValue attribute" );
|
||||
equals( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" );
|
||||
equals( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" );
|
||||
equals( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" );
|
||||
equals( jQuery("<option/>").prop("selected"), false, "Check selected attribute on disconnected element." );
|
||||
|
||||
equals( jQuery("#listWithTabIndex").prop("tabindex"), 5, "Check retrieving tabindex" );
|
||||
jQuery("#text1").prop("readonly", true);
|
||||
equals( document.getElementById("text1").readOnly, true, "Check setting readOnly property with 'readonly'" );
|
||||
equals( jQuery("#label-for").prop("for"), "action", "Check retrieving htmlFor" );
|
||||
jQuery("#text1").prop("class", "test");
|
||||
equals( document.getElementById("text1").className, "test", "Check setting className with 'class'" );
|
||||
equals( jQuery("#text1").prop("maxlength"), 30, "Check retrieving maxLength" );
|
||||
jQuery("#table").prop("cellspacing", 1);
|
||||
equals( jQuery("#table").prop("cellSpacing"), "1", "Check setting and retrieving cellSpacing" );
|
||||
jQuery("#table").prop("cellpadding", 1);
|
||||
equals( jQuery("#table").prop("cellPadding"), "1", "Check setting and retrieving cellPadding" );
|
||||
jQuery("#table").prop("rowspan", 1);
|
||||
equals( jQuery("#table").prop("rowSpan"), 1, "Check setting and retrieving rowSpan" );
|
||||
jQuery("#table").prop("colspan", 1);
|
||||
equals( jQuery("#table").prop("colSpan"), 1, "Check setting and retrieving colSpan" );
|
||||
jQuery("#table").prop("usemap", 1);
|
||||
equals( jQuery("#table").prop("useMap"), 1, "Check setting and retrieving useMap" );
|
||||
jQuery("#table").prop("frameborder", 1);
|
||||
equals( jQuery("#table").prop("frameBorder"), 1, "Check setting and retrieving frameBorder" );
|
||||
QUnit.reset();
|
||||
|
||||
var body = document.body, $body = jQuery( body );
|
||||
ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
|
||||
body.foo = "bar";
|
||||
equals( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
|
||||
body.foo = undefined;
|
||||
ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
|
||||
|
||||
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
|
||||
optgroup.appendChild( option );
|
||||
select.appendChild( optgroup );
|
||||
|
||||
equals( jQuery(option).prop("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
|
||||
equals( jQuery(document).prop("nodeName"), "#document", "prop works correctly on document nodes (bug #7451)." );
|
||||
|
||||
var attributeNode = document.createAttribute("irrelevant"),
|
||||
commentNode = document.createComment("some comment"),
|
||||
textNode = document.createTextNode("some text"),
|
||||
obj = {};
|
||||
jQuery.each( [document, attributeNode, commentNode, textNode, obj, "#firstp"], function( i, ele ) {
|
||||
strictEqual( jQuery(ele).prop("nonexisting"), undefined, "prop works correctly for non existing attributes (bug #7500)." );
|
||||
});
|
||||
|
||||
var obj = {};
|
||||
jQuery.each( [document, obj], function( i, ele ) {
|
||||
var $ele = jQuery( ele );
|
||||
$ele.prop( "nonexisting", "foo" );
|
||||
equal( $ele.prop("nonexisting"), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." );
|
||||
});
|
||||
jQuery( document ).removeProp("nonexisting");
|
||||
});
|
||||
|
||||
test("removeProp(String)", function() {
|
||||
|
@ -418,14 +535,14 @@ test("removeProp(String)", function() {
|
|||
strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
|
||||
});
|
||||
jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) {
|
||||
$ele = jQuery( ele );
|
||||
var $ele = jQuery( ele );
|
||||
$ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
|
||||
strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
|
||||
});
|
||||
});
|
||||
|
||||
test("val()", function() {
|
||||
expect(23);
|
||||
expect(26);
|
||||
|
||||
document.getElementById("text1").value = "bla";
|
||||
equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
|
||||
|
@ -487,8 +604,38 @@ test("val()", function() {
|
|||
same( checks.serialize(), "test=1&test=on", "Get multiple checked values." );
|
||||
|
||||
checks.remove();
|
||||
|
||||
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
|
||||
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
|
||||
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
|
||||
|
||||
equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
|
||||
});
|
||||
|
||||
if ( "value" in document.createElement("meter") &&
|
||||
"value" in document.createElement("progress") ) {
|
||||
|
||||
test("val() respects numbers without exception (Bug #9319)", function() {
|
||||
|
||||
expect(4);
|
||||
|
||||
var $meter = jQuery("<meter min='0' max='10' value='5.6'></meter>"),
|
||||
$progress = jQuery("<progress max='10' value='1.5'></progress>");
|
||||
|
||||
try {
|
||||
equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" );
|
||||
equal( $meter.val(), $meter[0].value, "meter, api matches host and does not throw exception" );
|
||||
|
||||
equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" );
|
||||
equal( $progress.val(), $progress[0].value, "progress, api matches host and does not throw exception" );
|
||||
|
||||
} catch(e) {}
|
||||
|
||||
$meter.remove();
|
||||
$progress.remove();
|
||||
});
|
||||
}
|
||||
|
||||
var testVal = function(valueObj) {
|
||||
expect(8);
|
||||
|
||||
|
@ -546,6 +693,7 @@ test( "val(Array of Numbers) (Bug #7123)", function() {
|
|||
test("val(Function) with incoming value", function() {
|
||||
expect(10);
|
||||
|
||||
QUnit.reset();
|
||||
var oldVal = jQuery("#text1").val();
|
||||
|
||||
jQuery("#text1").val(function(i, val) {
|
||||
|
@ -598,7 +746,7 @@ test("val(Function) with incoming value", function() {
|
|||
test("val(select) after form.reset() (Bug #2551)", function() {
|
||||
expect(3);
|
||||
|
||||
jQuery("<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>").appendTo("#main");
|
||||
jQuery("<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>").appendTo("#qunit-fixture");
|
||||
|
||||
jQuery("#kkk").val( "gf" );
|
||||
|
||||
|
@ -614,12 +762,15 @@ test("val(select) after form.reset() (Bug #2551)", function() {
|
|||
});
|
||||
|
||||
var testAddClass = function(valueObj) {
|
||||
expect(5);
|
||||
expect(9);
|
||||
|
||||
var div = jQuery("div");
|
||||
div.addClass( valueObj("test") );
|
||||
var pass = true;
|
||||
for ( var i = 0; i < div.size(); i++ ) {
|
||||
if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
|
||||
if ( !~div.get(i).className.indexOf("test") ) {
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
ok( pass, "Add Class" );
|
||||
|
||||
|
@ -640,6 +791,19 @@ var testAddClass = function(valueObj) {
|
|||
div.attr("class", "foo");
|
||||
div.addClass( valueObj("bar baz") );
|
||||
equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
|
||||
|
||||
div.removeClass();
|
||||
div.addClass( valueObj("foo") ).addClass( valueObj("foo") )
|
||||
equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." );
|
||||
|
||||
div.addClass( valueObj("fo") );
|
||||
equal( div.attr("class"), "foo fo", "Adding a similar class does not get interrupted." );
|
||||
div.removeClass().addClass("wrap2");
|
||||
ok( div.addClass("wrap").hasClass("wrap"), "Can add similarly named classes");
|
||||
|
||||
div.removeClass();
|
||||
div.addClass( valueObj("bar bar") );
|
||||
equal( div.attr("class"), "bar", "Do not add the same class twice in the same call." );
|
||||
};
|
||||
|
||||
test("addClass(String)", function() {
|
||||
|
@ -802,7 +966,7 @@ test("toggleClass(Function[, boolean])", function() {
|
|||
test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
|
||||
expect(14);
|
||||
|
||||
var e = jQuery("#firstp"), old = e.attr("class");
|
||||
var e = jQuery("#firstp"), old = e.attr("class") || "";
|
||||
ok( !e.is(".test"), "Assert class not present" );
|
||||
|
||||
e.toggleClass(function(i, val) {
|
||||
|
@ -890,4 +1054,4 @@ test("addClass, removeClass, hasClass", function() {
|
|||
ok( jq.hasClass("cla.ss3")==false, "Check the dotted class has been removed" );
|
||||
jq.removeClass("class4");
|
||||
ok( jq.hasClass("class4")==false, "Check the class has been properly removed" );
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ test("Basic requirements", function() {
|
|||
});
|
||||
|
||||
test("jQuery()", function() {
|
||||
expect(25);
|
||||
expect(29);
|
||||
|
||||
// Basic constructor's behavior
|
||||
|
||||
|
@ -29,7 +29,7 @@ test("jQuery()", function() {
|
|||
equals( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" );
|
||||
|
||||
|
||||
var main = jQuery("#main");
|
||||
var main = jQuery("#qunit-fixture");
|
||||
same( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
|
||||
|
||||
/*
|
||||
|
@ -96,6 +96,17 @@ test("jQuery()", function() {
|
|||
|
||||
// manually clean up detached elements
|
||||
elem.remove();
|
||||
|
||||
equals( jQuery(" <div/> ").length, 1, "Make sure whitespace is trimmed." );
|
||||
equals( jQuery(" a<div/>b ").length, 1, "Make sure whitespace and other characters are trimmed." );
|
||||
|
||||
var long = "";
|
||||
for ( var i = 0; i < 128; i++ ) {
|
||||
long += "12345678";
|
||||
}
|
||||
|
||||
equals( jQuery(" <div>" + long + "</div> ").length, 1, "Make sure whitespace is trimmed on long strings." );
|
||||
equals( jQuery(" a<div>" + long + "</div>b ").length, 1, "Make sure whitespace and other characters are trimmed on long strings." );
|
||||
});
|
||||
|
||||
test("selector state", function() {
|
||||
|
@ -115,54 +126,54 @@ test("selector state", function() {
|
|||
equals( test.selector, "", "Body Selector" );
|
||||
equals( test.context, document.body, "Body Context" );
|
||||
|
||||
test = jQuery("#main");
|
||||
equals( test.selector, "#main", "#main Selector" );
|
||||
equals( test.context, document, "#main Context" );
|
||||
test = jQuery("#qunit-fixture");
|
||||
equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
||||
equals( test.context, document, "#qunit-fixture Context" );
|
||||
|
||||
test = jQuery("#notfoundnono");
|
||||
equals( test.selector, "#notfoundnono", "#notfoundnono Selector" );
|
||||
equals( test.context, document, "#notfoundnono Context" );
|
||||
|
||||
test = jQuery("#main", document);
|
||||
equals( test.selector, "#main", "#main Selector" );
|
||||
equals( test.context, document, "#main Context" );
|
||||
test = jQuery("#qunit-fixture", document);
|
||||
equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
||||
equals( test.context, document, "#qunit-fixture Context" );
|
||||
|
||||
test = jQuery("#main", document.body);
|
||||
equals( test.selector, "#main", "#main Selector" );
|
||||
equals( test.context, document.body, "#main Context" );
|
||||
test = jQuery("#qunit-fixture", document.body);
|
||||
equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
||||
equals( test.context, document.body, "#qunit-fixture Context" );
|
||||
|
||||
// Test cloning
|
||||
test = jQuery(test);
|
||||
equals( test.selector, "#main", "#main Selector" );
|
||||
equals( test.context, document.body, "#main Context" );
|
||||
equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
||||
equals( test.context, document.body, "#qunit-fixture Context" );
|
||||
|
||||
test = jQuery(document.body).find("#main");
|
||||
equals( test.selector, "#main", "#main find Selector" );
|
||||
equals( test.context, document.body, "#main find Context" );
|
||||
test = jQuery(document.body).find("#qunit-fixture");
|
||||
equals( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" );
|
||||
equals( test.context, document.body, "#qunit-fixture find Context" );
|
||||
|
||||
test = jQuery("#main").filter("div");
|
||||
equals( test.selector, "#main.filter(div)", "#main filter Selector" );
|
||||
equals( test.context, document, "#main filter Context" );
|
||||
test = jQuery("#qunit-fixture").filter("div");
|
||||
equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter Selector" );
|
||||
equals( test.context, document, "#qunit-fixture filter Context" );
|
||||
|
||||
test = jQuery("#main").not("div");
|
||||
equals( test.selector, "#main.not(div)", "#main not Selector" );
|
||||
equals( test.context, document, "#main not Context" );
|
||||
test = jQuery("#qunit-fixture").not("div");
|
||||
equals( test.selector, "#qunit-fixture.not(div)", "#qunit-fixture not Selector" );
|
||||
equals( test.context, document, "#qunit-fixture not Context" );
|
||||
|
||||
test = jQuery("#main").filter("div").not("div");
|
||||
equals( test.selector, "#main.filter(div).not(div)", "#main filter, not Selector" );
|
||||
equals( test.context, document, "#main filter, not Context" );
|
||||
test = jQuery("#qunit-fixture").filter("div").not("div");
|
||||
equals( test.selector, "#qunit-fixture.filter(div).not(div)", "#qunit-fixture filter, not Selector" );
|
||||
equals( test.context, document, "#qunit-fixture filter, not Context" );
|
||||
|
||||
test = jQuery("#main").filter("div").not("div").end();
|
||||
equals( test.selector, "#main.filter(div)", "#main filter, not, end Selector" );
|
||||
equals( test.context, document, "#main filter, not, end Context" );
|
||||
test = jQuery("#qunit-fixture").filter("div").not("div").end();
|
||||
equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter, not, end Selector" );
|
||||
equals( test.context, document, "#qunit-fixture filter, not, end Context" );
|
||||
|
||||
test = jQuery("#main").parent("body");
|
||||
equals( test.selector, "#main.parent(body)", "#main parent Selector" );
|
||||
equals( test.context, document, "#main parent Context" );
|
||||
test = jQuery("#qunit-fixture").parent("body");
|
||||
equals( test.selector, "#qunit-fixture.parent(body)", "#qunit-fixture parent Selector" );
|
||||
equals( test.context, document, "#qunit-fixture parent Context" );
|
||||
|
||||
test = jQuery("#main").eq(0);
|
||||
equals( test.selector, "#main.slice(0,1)", "#main eq Selector" );
|
||||
equals( test.context, document, "#main eq Context" );
|
||||
test = jQuery("#qunit-fixture").eq(0);
|
||||
equals( test.selector, "#qunit-fixture.slice(0,1)", "#qunit-fixture eq Selector" );
|
||||
equals( test.context, document, "#qunit-fixture eq Context" );
|
||||
|
||||
var d = "<div />";
|
||||
equals(
|
||||
|
@ -228,7 +239,7 @@ test("noConflict", function() {
|
|||
equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
|
||||
equals( jQuery, originaljQuery, "Make sure jQuery was reverted." );
|
||||
equals( $, original$, "Make sure $ was reverted." );
|
||||
ok( $$("#main").html("test"), "Make sure that jQuery still works." );
|
||||
ok( $$("#qunit-fixture").html("test"), "Make sure that jQuery still works." );
|
||||
|
||||
jQuery = $$;
|
||||
});
|
||||
|
@ -571,29 +582,29 @@ test("end()", function() {
|
|||
|
||||
test("length", function() {
|
||||
expect(1);
|
||||
equals( jQuery("#main p").length, 6, "Get Number of Elements Found" );
|
||||
equals( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" );
|
||||
});
|
||||
|
||||
test("size()", function() {
|
||||
expect(1);
|
||||
equals( jQuery("#main p").size(), 6, "Get Number of Elements Found" );
|
||||
equals( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" );
|
||||
});
|
||||
|
||||
test("get()", function() {
|
||||
expect(1);
|
||||
same( jQuery("#main p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
|
||||
same( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
|
||||
});
|
||||
|
||||
test("toArray()", function() {
|
||||
expect(1);
|
||||
same( jQuery("#main p").toArray(),
|
||||
same( jQuery("#qunit-fixture p").toArray(),
|
||||
q("firstp","ap","sndp","en","sap","first"),
|
||||
"Convert jQuery object to an Array" )
|
||||
})
|
||||
|
||||
test("get(Number)", function() {
|
||||
expect(2);
|
||||
equals( jQuery("#main p").get(0), document.getElementById("firstp"), "Get A Single Element" );
|
||||
equals( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" );
|
||||
strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" );
|
||||
});
|
||||
|
||||
|
@ -642,7 +653,7 @@ test("first()/last()", function() {
|
|||
});
|
||||
|
||||
test("map()", function() {
|
||||
expect(7);
|
||||
expect(8);
|
||||
|
||||
same(
|
||||
jQuery("#ap").map(function(){
|
||||
|
@ -683,6 +694,12 @@ test("map()", function() {
|
|||
});
|
||||
equals( mapped.length, scripts.length, "Map an array(-like) to a hash" );
|
||||
|
||||
var nonsense = document.getElementsByTagName("asdf");
|
||||
var mapped = jQuery.map( nonsense, function( v, k ){
|
||||
return v;
|
||||
});
|
||||
equals( mapped.length, nonsense.length, "Map an empty array(-like) to a hash" );
|
||||
|
||||
var flat = jQuery.map( Array(4), function( v, k ){
|
||||
return k % 2 ? k : [k,k,k];//try mixing array and regular returns
|
||||
});
|
||||
|
@ -910,7 +927,7 @@ test("jQuery.isEmptyObject", function(){
|
|||
});
|
||||
|
||||
test("jQuery.proxy", function(){
|
||||
expect(6);
|
||||
expect(7);
|
||||
|
||||
var test = function(){ equals( this, thisObject, "Make sure that scope is set properly." ); };
|
||||
var thisObject = { foo: "bar", method: test };
|
||||
|
@ -921,6 +938,9 @@ test("jQuery.proxy", function(){
|
|||
// Basic scoping
|
||||
jQuery.proxy( test, thisObject )();
|
||||
|
||||
// Another take on it
|
||||
jQuery.proxy( thisObject, "method" )();
|
||||
|
||||
// Make sure it doesn't freak out
|
||||
equals( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." );
|
||||
|
||||
|
@ -1084,3 +1104,17 @@ test("jQuery.sub() - .fn Methods", function(){
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
test("jQuery.camelCase()", function() {
|
||||
|
||||
var tests = {
|
||||
"foo-bar": "fooBar",
|
||||
"foo-bar-baz": "fooBarBaz"
|
||||
};
|
||||
|
||||
expect(2);
|
||||
|
||||
jQuery.each( tests, function( key, val ) {
|
||||
equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ module("css", { teardown: moduleTeardown });
|
|||
test("css(String|Hash)", function() {
|
||||
expect( 42 );
|
||||
|
||||
equals( jQuery("#main").css("display"), "block", "Check for css property \"display\"");
|
||||
equals( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\"");
|
||||
|
||||
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible");
|
||||
jQuery("#nothiddendiv").css({display: "none"});
|
||||
|
@ -45,9 +45,9 @@ test("css(String|Hash)", function() {
|
|||
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" );
|
||||
|
@ -109,11 +109,13 @@ test("css(String|Hash)", function() {
|
|||
});
|
||||
|
||||
test("css() explicit and relative values", function() {
|
||||
expect(9);
|
||||
expect(27);
|
||||
var $elem = jQuery("#nothiddendiv");
|
||||
|
||||
$elem.css({ width: 1, height: 1 });
|
||||
$elem.css({ width: 1, height: 1, paddingLeft: "1px", opacity: 1 });
|
||||
equals( $elem.width(), 1, "Initial css set or width/height works (hash)" );
|
||||
equals( $elem.css("paddingLeft"), "1px", "Initial css set of paddingLeft works (hash)" );
|
||||
equals( $elem.css("opacity"), "1", "Initial css set of opacity works (hash)" );
|
||||
|
||||
$elem.css({ width: "+=9" });
|
||||
equals( $elem.width(), 10, "'+=9' on width (hash)" );
|
||||
|
@ -138,6 +140,54 @@ test("css() explicit and relative values", function() {
|
|||
|
||||
$elem.css( "width", "-=9px" );
|
||||
equals( $elem.width(), 1, "'-=9px' on width (params)" );
|
||||
|
||||
$elem.css({ paddingLeft: "+=4" });
|
||||
equals( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ paddingLeft: "-=4" });
|
||||
equals( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ paddingLeft: "+=4px" });
|
||||
equals( $elem.css("paddingLeft"), "5px", "'+=4px' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ paddingLeft: "-=4px" });
|
||||
equals( $elem.css("paddingLeft"), "1px", "'-=4px' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ "padding-left": "+=4" });
|
||||
equals( $elem.css("paddingLeft"), "5px", "'+=4' on padding-left (hash)" );
|
||||
|
||||
$elem.css({ "padding-left": "-=4" });
|
||||
equals( $elem.css("paddingLeft"), "1px", "'-=4' on padding-left (hash)" );
|
||||
|
||||
$elem.css({ "padding-left": "+=4px" });
|
||||
equals( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (hash)" );
|
||||
|
||||
$elem.css({ "padding-left": "-=4px" });
|
||||
equals( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (hash)" );
|
||||
|
||||
$elem.css( "paddingLeft", "+=4" );
|
||||
equals( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (params)" );
|
||||
|
||||
$elem.css( "paddingLeft", "-=4" );
|
||||
equals( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (params)" );
|
||||
|
||||
$elem.css( "padding-left", "+=4px" );
|
||||
equals( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (params)" );
|
||||
|
||||
$elem.css( "padding-left", "-=4px" );
|
||||
equals( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (params)" );
|
||||
|
||||
$elem.css({ opacity: "-=0.5" });
|
||||
equals( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (hash)" );
|
||||
|
||||
$elem.css({ opacity: "+=0.5" });
|
||||
equals( $elem.css("opacity"), "1", "'+=0.5' on opacity (hash)" );
|
||||
|
||||
$elem.css( "opacity", "-=0.5" );
|
||||
equals( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (params)" );
|
||||
|
||||
$elem.css( "opacity", "+=0.5" );
|
||||
equals( $elem.css("opacity"), "1", "'+=0.5' on opacity (params)" );
|
||||
});
|
||||
|
||||
test("css(String, Object)", function() {
|
||||
|
@ -394,3 +444,44 @@ test("jQuery.cssProps behavior, (bug #8402)", function() {
|
|||
// cleanup jQuery.cssProps
|
||||
jQuery.cssProps.top = undefined;
|
||||
});
|
||||
|
||||
test("widows & orphans #8936", function () {
|
||||
|
||||
var $p = jQuery("<p>").appendTo("#qunit-fixture");
|
||||
|
||||
if ( "widows" in $p[0].style ) {
|
||||
expect(4);
|
||||
$p.css({
|
||||
widows: 0,
|
||||
orphans: 0
|
||||
});
|
||||
|
||||
equal( $p.css("widows") || jQuery.style( $p[0], "widows" ), 0, "widows correctly start with value 0");
|
||||
equal( $p.css("orphans") || jQuery.style( $p[0], "orphans" ), 0, "orphans correctly start with value 0");
|
||||
|
||||
$p.css({
|
||||
widows: 3,
|
||||
orphans: 3
|
||||
});
|
||||
|
||||
equal( $p.css("widows") || jQuery.style( $p[0], "widows" ), 3, "widows correctly set to 3");
|
||||
equal( $p.css("orphans") || jQuery.style( $p[0], "orphans" ), 3, "orphans correctly set to 3");
|
||||
} else {
|
||||
|
||||
expect(1);
|
||||
ok( true, "jQuery does not attempt to test for style props that definitely don't exist in older versions of IE");
|
||||
}
|
||||
|
||||
|
||||
$p.remove();
|
||||
});
|
||||
|
||||
test("Do not append px to 'fill-opacity' #9548", 1, function() {
|
||||
|
||||
var $div = jQuery("<div>").appendTo("#qunit-fixture");
|
||||
|
||||
$div.css("fill-opacity", 0).animate({ "fill-opacity": 1.0 }, 0, function () {
|
||||
equal( jQuery(this).css("fill-opacity"), 1, "Do not append px to 'fill-opacity'");
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -316,7 +316,7 @@ test("data-* attributes", function() {
|
|||
|
||||
div.remove();
|
||||
|
||||
child.appendTo("#main");
|
||||
child.appendTo("#qunit-fixture");
|
||||
equals( child.data("myobj"), "old data", "Value accessed from data-* attribute");
|
||||
|
||||
child.data("myobj", "replaced");
|
||||
|
@ -406,7 +406,7 @@ test("data-* attributes", function() {
|
|||
}
|
||||
|
||||
var metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>",
|
||||
elem = jQuery(metadata).appendTo("#main");
|
||||
elem = jQuery(metadata).appendTo("#qunit-fixture");
|
||||
|
||||
elem.find("li").each(testData);
|
||||
elem.remove();
|
||||
|
@ -488,7 +488,7 @@ if (window.JSON && window.JSON.stringify) {
|
|||
}
|
||||
|
||||
test("jQuery.data should follow html5 specification regarding camel casing", function() {
|
||||
expect(6);
|
||||
expect(8);
|
||||
|
||||
var div = jQuery("<div id='myObject' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>")
|
||||
.prependTo("body");
|
||||
|
@ -501,5 +501,27 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
|
|||
equals(div.data("fooBar"), "b", "Verify multiple word data-* key");
|
||||
equals(div.data("fooBarBaz"), "c", "Verify multiple word data-* key");
|
||||
|
||||
div.data("foo-bar", "d");
|
||||
|
||||
equals(div.data("fooBar"), "d", "Verify updated data-* key");
|
||||
equals(div.data("foo-bar"), "d", "Verify updated data-* key");
|
||||
|
||||
div.remove();
|
||||
});
|
||||
});
|
||||
|
||||
test("jQuery.data should not miss data with preset hyphenated property names", function() {
|
||||
|
||||
expect(2);
|
||||
|
||||
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
||||
test = {
|
||||
"camelBar": "camelBar",
|
||||
"hyphen-foo": "hyphen-foo"
|
||||
};
|
||||
|
||||
div.data( test );
|
||||
|
||||
jQuery.each( test , function(i, k) {
|
||||
equal( div.data(k), k, "data with property '"+k+"' was correctly found");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -145,7 +145,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
|||
|
||||
test( "jQuery.Deferred.pipe - filtering (done)", function() {
|
||||
|
||||
expect(3);
|
||||
expect(4);
|
||||
|
||||
var defer = jQuery.Deferred(),
|
||||
piped = defer.pipe(function( a, b ) {
|
||||
|
@ -173,11 +173,15 @@ test( "jQuery.Deferred.pipe - filtering (done)", function() {
|
|||
jQuery.Deferred().reject().pipe(function() {
|
||||
ok( false, "pipe should not be called on reject" );
|
||||
});
|
||||
|
||||
jQuery.Deferred().resolve().pipe( jQuery.noop ).done(function( value ) {
|
||||
strictEqual( value, undefined, "pipe done callback can return undefined/null" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.pipe - filtering (fail)", function() {
|
||||
|
||||
expect(3);
|
||||
expect(4);
|
||||
|
||||
var defer = jQuery.Deferred(),
|
||||
piped = defer.pipe( null, function( a, b ) {
|
||||
|
@ -205,6 +209,10 @@ test( "jQuery.Deferred.pipe - filtering (fail)", function() {
|
|||
jQuery.Deferred().resolve().pipe( null, function() {
|
||||
ok( false, "pipe should not be called on resolve" );
|
||||
} );
|
||||
|
||||
jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail(function( value ) {
|
||||
strictEqual( value, undefined, "pipe fail callback can return undefined/null" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.pipe - deferred (done)", function() {
|
||||
|
@ -267,6 +275,33 @@ test( "jQuery.Deferred.pipe - deferred (fail)", function() {
|
|||
strictEqual( value3, 6, "result of filter ok" );
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.pipe - context", function() {
|
||||
|
||||
expect(4);
|
||||
|
||||
var context = {};
|
||||
|
||||
jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe(function( value ) {
|
||||
return value * 3;
|
||||
}).done(function( value ) {
|
||||
strictEqual( this, context, "custom context correctly propagated" );
|
||||
strictEqual( value, 6, "proper value received" );
|
||||
});
|
||||
|
||||
var defer = jQuery.Deferred(),
|
||||
piped = defer.pipe(function( value ) {
|
||||
return value * 3;
|
||||
});
|
||||
|
||||
defer.resolve( 2 );
|
||||
|
||||
piped.done(function( value ) {
|
||||
strictEqual( this.promise(), piped, "default context gets updated to latest defer in the chain" );
|
||||
strictEqual( value, 6, "proper value received" );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test( "jQuery.when" , function() {
|
||||
|
||||
expect( 23 );
|
||||
|
|
|
@ -107,7 +107,13 @@ test("height() with function args", function() {
|
|||
});
|
||||
|
||||
test("innerWidth()", function() {
|
||||
expect(4);
|
||||
expect(8);
|
||||
|
||||
equals(jQuery(window).innerWidth(), null, "Test on window without margin option");
|
||||
equals(jQuery(window).innerWidth(true), null, "Test on window with margin option");
|
||||
|
||||
equals(jQuery(document).innerWidth(), null, "Test on document without margin option");
|
||||
equals(jQuery(document).innerWidth(true), null, "Test on document with margin option");
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
// set styles
|
||||
|
@ -136,7 +142,13 @@ test("innerWidth()", function() {
|
|||
});
|
||||
|
||||
test("innerHeight()", function() {
|
||||
expect(4);
|
||||
expect(8);
|
||||
|
||||
equals(jQuery(window).innerHeight(), null, "Test on window without margin option");
|
||||
equals(jQuery(window).innerHeight(true), null, "Test on window with margin option");
|
||||
|
||||
equals(jQuery(document).innerHeight(), null, "Test on document without margin option");
|
||||
equals(jQuery(document).innerHeight(true), null, "Test on document with margin option");
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
// set styles
|
||||
|
@ -165,7 +177,12 @@ test("innerHeight()", function() {
|
|||
});
|
||||
|
||||
test("outerWidth()", function() {
|
||||
expect(7);
|
||||
expect(11);
|
||||
|
||||
equal( jQuery( window ).outerWidth(), null, "Test on window without margin option" );
|
||||
equal( jQuery( window ).outerWidth( true ), null, "Test on window with margin option" );
|
||||
equal( jQuery( document ).outerWidth(), null, "Test on document without margin option" );
|
||||
equal( jQuery( document ).outerWidth( true ), null, "Test on document with margin option" );
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
$div.css("width", 30);
|
||||
|
@ -194,8 +211,38 @@ test("outerWidth()", function() {
|
|||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
});
|
||||
|
||||
test("child of a hidden elem has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
|
||||
expect(8);
|
||||
|
||||
// setup html
|
||||
var $divNormal = jQuery("<div>").css({ width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
|
||||
$divChild = $divNormal.clone(),
|
||||
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
||||
$divNormal.appendTo("body");
|
||||
|
||||
// tests that child div of a hidden div works the same as a normal div
|
||||
equals( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
|
||||
equals( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
|
||||
equals( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
|
||||
equals( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
|
||||
|
||||
equals( $divChild.height(), $divNormal.height(), "child of a hidden element height() is wrong see #9441" );
|
||||
equals( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #9441" );
|
||||
equals( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #9441" );
|
||||
equals( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
|
||||
|
||||
// teardown html
|
||||
$divHiddenParent.remove();
|
||||
$divNormal.remove();
|
||||
});
|
||||
|
||||
test("outerHeight()", function() {
|
||||
expect(7);
|
||||
expect(11);
|
||||
|
||||
equal( jQuery( window ).outerHeight(), null, "Test on window without margin option" );
|
||||
equal( jQuery( window ).outerHeight( true ), null, "Test on window with margin option" );
|
||||
equal( jQuery( document ).outerHeight(), null, "Test on document without margin option" );
|
||||
equal( jQuery( document ).outerHeight( true ), null, "Test on document with margin option" );
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
$div.css("height", 30);
|
||||
|
@ -222,82 +269,3 @@ test("outerHeight()", function() {
|
|||
div.remove();
|
||||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
});
|
||||
|
||||
test('width(), outerWidth(), innerWidth(), height(), outerHeight() and innerHeight() with inputs', function(){
|
||||
expect(47);
|
||||
|
||||
var id = 'input-width-test-group';
|
||||
var input_els = 'submit reset button'.split(' ');
|
||||
var html = '<div id="' + id + '" style="width:100px;">';
|
||||
var style = 'width:35px;height:50px;padding:5px;border:1px solid #000;margin:2px;';
|
||||
|
||||
html += '<div id="nothing-set-div">test</div>';
|
||||
html += '<div id="width-div-1" style="' + style + '">something</div>';
|
||||
html += '<button id="width-button-1" style="' + style + '">button</button>';
|
||||
jQuery.each(input_els, function() {
|
||||
html += '<input class="width-input" type="' + this + '" style="' + style + '" />';
|
||||
});
|
||||
html += '</div>';
|
||||
|
||||
jQuery('#main').append(html);
|
||||
|
||||
equals(jQuery('#nothing-set-div').width(), 100, 'Width of unset div takes on parent');
|
||||
|
||||
jQuery('#width-div-1, #width-button-1, .width-input').each(function(){
|
||||
|
||||
// Test widths
|
||||
var w = jQuery(this).width();
|
||||
var outer_w = jQuery(this).outerWidth();
|
||||
var outer_w_margin = jQuery(this).outerWidth(true);
|
||||
var inner_w = jQuery(this).innerWidth();
|
||||
var t = this.tagName.toLowerCase() + ((this.type) ? '[' + this.type + ']' : '');
|
||||
|
||||
equals(w, 35, 'Make sure width() works for ' + t);
|
||||
equals(outer_w, 47, 'Make sure outerWidth() works for ' + t);
|
||||
equals(outer_w_margin, 51, 'Make sure outerWidth(true) works for ' + t);
|
||||
equals(inner_w, 45, 'Make sure innerWidth() works for ' + t);
|
||||
|
||||
// Test heights
|
||||
var h = jQuery(this).height();
|
||||
var outer_h = jQuery(this).outerHeight();
|
||||
var outer_h_margin = jQuery(this).outerHeight(true);
|
||||
var inner_h = jQuery(this).innerHeight();
|
||||
|
||||
equals(h, 50, 'Make sure height() works for ' + t);
|
||||
equals(outer_h, 62, 'Make sure outerHeight() works for ' + t);
|
||||
equals(outer_h_margin, 66, 'Make sure outerHeight(true) works for ' + t);
|
||||
equals(inner_h, 60, 'Make sure innerHeight() works for ' + t);
|
||||
|
||||
});
|
||||
|
||||
var inputsub = jQuery('.width-input').filter('input[type=submit]');
|
||||
|
||||
inputsub.css({
|
||||
width: 10,
|
||||
padding: 0,
|
||||
margin: '3px',
|
||||
border: '1px solid red',
|
||||
height: 15
|
||||
});
|
||||
|
||||
var w = inputsub.width();
|
||||
equals(w, 10, 'width() works after setting css using .css()');
|
||||
|
||||
var outer_w = inputsub.outerWidth();
|
||||
equals(outer_w, 12, 'outerWidth() works after setting css using .css()');
|
||||
|
||||
var outer_w_margin = inputsub.outerWidth(true);
|
||||
equals(outer_w_margin, 18, 'outerWidth(true) works after setting css using .css()');
|
||||
|
||||
var h = inputsub.height();
|
||||
equals(h, 15, 'height() works after setting css using .css()');
|
||||
|
||||
var outer_h = inputsub.outerHeight();
|
||||
equals(outer_h, 17, 'outerHeight() works after setting css using .css()');
|
||||
|
||||
var outer_h_margin = inputsub.outerHeight(true);
|
||||
equals(outer_h_margin, 23, 'outerHeight(true) works after setting css using .css()');
|
||||
|
||||
jQuery('#' + id).remove();
|
||||
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ module("effects", { teardown: moduleTeardown });
|
|||
|
||||
test("sanity check", function() {
|
||||
expect(1);
|
||||
ok( jQuery("#dl:visible, #main:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" );
|
||||
ok( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" );
|
||||
});
|
||||
|
||||
test("show()", function() {
|
||||
|
@ -14,7 +14,7 @@ test("show()", function() {
|
|||
|
||||
equals( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." );
|
||||
|
||||
var div = jQuery("<div>").hide().appendTo("#main").show();
|
||||
var div = jQuery("<div>").hide().appendTo("#qunit-fixture").show();
|
||||
|
||||
equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
|
||||
|
||||
|
@ -32,7 +32,8 @@ test("show()", function() {
|
|||
|
||||
hiddendiv.css("display","");
|
||||
|
||||
var pass = true, div = jQuery("#main div");
|
||||
var pass = true;
|
||||
div = jQuery("#qunit-fixture div");
|
||||
div.show().each(function(){
|
||||
if ( this.style.display == "none" ) pass = false;
|
||||
});
|
||||
|
@ -62,7 +63,7 @@ test("show()", function() {
|
|||
});
|
||||
|
||||
// #show-tests * is set display: none in CSS
|
||||
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
||||
jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
||||
|
||||
var old = jQuery("#test-table").show().css("display") !== "table";
|
||||
jQuery("#test-table").remove();
|
||||
|
@ -88,6 +89,10 @@ test("show()", function() {
|
|||
var elem = jQuery(selector, "#show-tests").show();
|
||||
equals( elem.css("display"), expected, "Show using correct display type for " + selector );
|
||||
});
|
||||
|
||||
// Make sure that showing or hiding a text node doesn't cause an error
|
||||
jQuery("<div>test</div> text <span>test</span>").show().remove();
|
||||
jQuery("<div>test</div> text <span>test</span>").hide().remove();
|
||||
});
|
||||
|
||||
test("show(Number) - other displays", function() {
|
||||
|
@ -96,7 +101,7 @@ test("show(Number) - other displays", function() {
|
|||
stop();
|
||||
|
||||
// #show-tests * is set display: none in CSS
|
||||
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
||||
jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
||||
|
||||
var old = jQuery("#test-table").show().css("display") !== "table",
|
||||
num = 0;
|
||||
|
@ -138,7 +143,7 @@ test("Persist correct display value", function() {
|
|||
stop();
|
||||
|
||||
// #show-tests * is set display: none in CSS
|
||||
jQuery("#main").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>");
|
||||
jQuery("#qunit-fixture").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>");
|
||||
|
||||
var $span = jQuery("#show-tests span"),
|
||||
displayNone = $span.css("display"),
|
||||
|
@ -578,10 +583,10 @@ jQuery.checkOverflowDisplay = function(){
|
|||
equals(jQuery.css( this, "display" ), "inline", "Display shouldn't be tampered with.");
|
||||
|
||||
start();
|
||||
}
|
||||
};
|
||||
|
||||
test( "jQuery.fx.prototype.cur()", 6, function() {
|
||||
var div = jQuery( "<div></div>" ).appendTo( "#main" ).css({
|
||||
var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({
|
||||
color: "#ABC",
|
||||
border: "5px solid black",
|
||||
left: "auto",
|
||||
|
@ -690,8 +695,8 @@ jQuery.each( {
|
|||
jQuery(elem).css(prop,prop == "opacity" ? 0 : "0px");
|
||||
return 0;
|
||||
}
|
||||
}, function(fn, f){
|
||||
jQuery.each( {
|
||||
}, function( fn, f ) {
|
||||
jQuery.each({
|
||||
"show": function(elem,prop){
|
||||
jQuery(elem).hide().addClass("wide"+prop);
|
||||
return "show";
|
||||
|
@ -897,7 +902,7 @@ jQuery.makeTest = function( text ){
|
|||
.after( elem );
|
||||
|
||||
return elem;
|
||||
}
|
||||
};
|
||||
|
||||
jQuery.makeTest.id = 1;
|
||||
|
||||
|
@ -918,34 +923,42 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
|
|||
|
||||
test("animate with per-property easing", function(){
|
||||
|
||||
expect(3);
|
||||
expect(5);
|
||||
stop();
|
||||
|
||||
var _test1_called = false;
|
||||
var _test2_called = false;
|
||||
var _default_test_called = false;
|
||||
var data = { a:0, b:0, c:0 },
|
||||
_test1_called = false,
|
||||
_test2_called = false,
|
||||
_default_test_called = false,
|
||||
props = {
|
||||
a: [ 100, "_test1" ],
|
||||
b: [ 100, "_test2" ],
|
||||
c: 100
|
||||
};
|
||||
|
||||
jQuery.easing["_test1"] = function() {
|
||||
jQuery.easing["_test1"] = function(p) {
|
||||
_test1_called = true;
|
||||
return p;
|
||||
};
|
||||
|
||||
jQuery.easing["_test2"] = function() {
|
||||
jQuery.easing["_test2"] = function(p) {
|
||||
_test2_called = true;
|
||||
return p;
|
||||
};
|
||||
|
||||
jQuery.easing["_default_test"] = function() {
|
||||
jQuery.easing["_default_test"] = function(p) {
|
||||
_default_test_called = true;
|
||||
return p;
|
||||
};
|
||||
|
||||
jQuery({a:0,b:0,c:0}).animate({
|
||||
a: [100, "_test1"],
|
||||
b: [100, "_test2"],
|
||||
c: 100
|
||||
}, 400, "_default_test", function(){
|
||||
jQuery(data).animate( props, 400, "_default_test", function(){
|
||||
start();
|
||||
ok(_test1_called, "Easing function (1) called");
|
||||
ok(_test2_called, "Easing function (2) called");
|
||||
ok(_default_test_called, "Easing function (_default) called");
|
||||
|
||||
ok( _test1_called, "Easing function (_test1) called" );
|
||||
ok( _test2_called, "Easing function (_test2) called" );
|
||||
ok( _default_test_called, "Easing function (_default) called" );
|
||||
equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)");
|
||||
equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)");
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -954,7 +967,7 @@ test("hide hidden elements (bug #7141)", function() {
|
|||
expect(3);
|
||||
QUnit.reset();
|
||||
|
||||
var div = jQuery("<div style='display:none'></div>").appendTo("#main");
|
||||
var div = jQuery("<div style='display:none'></div>").appendTo("#qunit-fixture");
|
||||
equals( div.css("display"), "none", "Element is hidden by default" );
|
||||
div.hide();
|
||||
ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
|
||||
|
@ -969,7 +982,7 @@ test("hide hidden elements, with animation (bug #7141)", function() {
|
|||
QUnit.reset();
|
||||
stop();
|
||||
|
||||
var div = jQuery("<div style='display:none'></div>").appendTo("#main");
|
||||
var div = jQuery("<div style='display:none'></div>").appendTo("#qunit-fixture");
|
||||
equals( div.css("display"), "none", "Element is hidden by default" );
|
||||
div.hide(1, function () {
|
||||
ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
|
||||
|
@ -982,10 +995,53 @@ test("hide hidden elements, with animation (bug #7141)", function() {
|
|||
|
||||
test("animate unit-less properties (#4966)", 2, function() {
|
||||
stop();
|
||||
var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).appendTo( "#main" );
|
||||
var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).appendTo( "#qunit-fixture" );
|
||||
equal( div.css( "z-index" ), "0", "z-index is 0" );
|
||||
div.animate({ zIndex: 2 }, function() {
|
||||
equal( div.css( "z-index" ), "2", "z-index is 2" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test( "animate properties missing px w/ opacity as last (#9074)", 2, function() {
|
||||
expect( 6 );
|
||||
stop();
|
||||
var div = jQuery( "<div style='position: absolute; margin-left: 0; left: 0px;'></div>" )
|
||||
.appendTo( "#qunit-fixture" );
|
||||
function cssInt( prop ) {
|
||||
return parseInt( div.css( prop ), 10 );
|
||||
}
|
||||
equal( cssInt( "marginLeft" ), 0, "Margin left is 0" );
|
||||
equal( cssInt( "left" ), 0, "Left is 0" );
|
||||
div.animate({
|
||||
left: 200,
|
||||
marginLeft: 200,
|
||||
opacity: 0
|
||||
}, 1000);
|
||||
setTimeout(function() {
|
||||
var ml = cssInt( "marginLeft" ),
|
||||
l = cssInt( "left" );
|
||||
notEqual( ml, 0, "Margin left is not 0 after partial animate" );
|
||||
notEqual( ml, 200, "Margin left is not 200 after partial animate" );
|
||||
notEqual( l, 0, "Left is not 0 after partial animate" );
|
||||
notEqual( l, 200, "Left is not 200 after partial animate" );
|
||||
div.stop().remove();
|
||||
start();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
test("callbacks should fire in correct order (#9100)", function() {
|
||||
stop();
|
||||
var a = 1,
|
||||
cb = 0,
|
||||
$lis = jQuery("<p data-operation='*2'></p><p data-operation='^2'></p>").appendTo("#qunit-fixture")
|
||||
// The test will always pass if no properties are animated or if the duration is 0
|
||||
.animate({fontSize: 12}, 13, function() {
|
||||
a *= jQuery(this).data("operation") === "*2" ? 2 : a;
|
||||
cb++;
|
||||
if ( cb === 2 ) {
|
||||
equal( a, 4, "test value has been *2 and _then_ ^2");
|
||||
start();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,8 +14,28 @@ test("null or undefined handler", function() {
|
|||
} catch (e) {}
|
||||
});
|
||||
|
||||
test("bind(), with data", function() {
|
||||
test("bind(),live(),delegate() with non-null,defined data", function() {
|
||||
|
||||
expect(3);
|
||||
|
||||
var handler = function( event, data ) {
|
||||
equal( data, 0, "non-null, defined data (zero) is correctly passed" );
|
||||
};
|
||||
|
||||
jQuery("#foo").bind("foo", handler);
|
||||
jQuery("#foo").live("foo", handler);
|
||||
jQuery("div").delegate("#foo", "foo", handler);
|
||||
|
||||
jQuery("#foo").trigger("foo", 0);
|
||||
|
||||
jQuery("#foo").unbind("foo", handler);
|
||||
jQuery("#foo").die("foo", handler);
|
||||
jQuery("div").undelegate("#foo", "foo");
|
||||
|
||||
});
|
||||
|
||||
test("bind(), with data", function() {
|
||||
expect(4);
|
||||
var handler = function(event) {
|
||||
ok( event.data, "bind() with data, check passed data exists" );
|
||||
equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );
|
||||
|
@ -23,6 +43,12 @@ test("bind(), with data", function() {
|
|||
jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);
|
||||
|
||||
ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
|
||||
|
||||
var test = function(){};
|
||||
var handler2 = function(event) {
|
||||
equals( event.data, test, "bind() with function data, Check value of passed data" );
|
||||
};
|
||||
jQuery("#firstp").bind("click", test, handler2).click().unbind("click", handler2);
|
||||
});
|
||||
|
||||
test("click(), with data", function() {
|
||||
|
@ -62,6 +88,22 @@ test("bind(), multiple events at once", function() {
|
|||
equals( mouseoverCounter, 1, "bind() with multiple events at once" );
|
||||
});
|
||||
|
||||
test("bind(), five events at once", function() {
|
||||
expect(1);
|
||||
|
||||
var count = 0,
|
||||
handler = function(event) {
|
||||
count++;
|
||||
};
|
||||
|
||||
jQuery("#firstp").bind("click mouseover foo bar baz", handler)
|
||||
.trigger("click").trigger("mouseover")
|
||||
.trigger("foo").trigger("bar")
|
||||
.trigger("baz");
|
||||
|
||||
equals( count, 5, "bind() five events at once" );
|
||||
});
|
||||
|
||||
test("bind(), multiple events at once and namespaces", function() {
|
||||
expect(7);
|
||||
|
||||
|
@ -163,7 +205,7 @@ test("bind(), namespace with special add", function() {
|
|||
});
|
||||
|
||||
// Should trigger 2
|
||||
div.appendTo("#main").remove();
|
||||
div.appendTo("#qunit-fixture").remove();
|
||||
|
||||
delete jQuery.event.special.test;
|
||||
});
|
||||
|
@ -301,7 +343,7 @@ test("live/delegate immediate propagation", function() {
|
|||
test("bind/delegate bubbling, isDefaultPrevented", function() {
|
||||
expect(2);
|
||||
var $anchor2 = jQuery( "#anchor2" ),
|
||||
$main = jQuery( "#main" ),
|
||||
$main = jQuery( "#qunit-fixture" ),
|
||||
fakeClick = function($jq) {
|
||||
// Use a native click so we don't get jQuery simulated bubbling
|
||||
if ( document.createEvent ) {
|
||||
|
@ -409,7 +451,7 @@ test("bind(), namespaced events, cloned events", 18, function() {
|
|||
}).trigger("tester");
|
||||
|
||||
// Make sure events stick with appendTo'd elements (which are cloned) #2027
|
||||
jQuery("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("#main");
|
||||
jQuery("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("#qunit-fixture");
|
||||
ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
|
||||
});
|
||||
|
||||
|
@ -532,7 +574,7 @@ test("bind(name, false), unbind(name, false)", function() {
|
|||
expect(3);
|
||||
|
||||
var main = 0;
|
||||
jQuery("#main").bind("click", function(e){ main++; });
|
||||
jQuery("#qunit-fixture").bind("click", function(e){ main++; });
|
||||
jQuery("#ap").trigger("click");
|
||||
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||
|
||||
|
@ -547,14 +589,14 @@ test("bind(name, false), unbind(name, false)", function() {
|
|||
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||
|
||||
// manually clean up events from elements outside the fixture
|
||||
jQuery("#main").unbind("click");
|
||||
jQuery("#qunit-fixture").unbind("click");
|
||||
});
|
||||
|
||||
test("live(name, false), die(name, false)", function() {
|
||||
expect(3);
|
||||
|
||||
var main = 0;
|
||||
jQuery("#main").live("click", function(e){ main++; });
|
||||
jQuery("#qunit-fixture").live("click", function(e){ main++; });
|
||||
jQuery("#ap").trigger("click");
|
||||
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||
|
||||
|
@ -567,7 +609,7 @@ test("live(name, false), die(name, false)", function() {
|
|||
jQuery("#ap").die("click", false);
|
||||
jQuery("#ap").trigger("click");
|
||||
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||
jQuery("#main").die("click");
|
||||
jQuery("#qunit-fixture").die("click");
|
||||
});
|
||||
|
||||
test("delegate(selector, name, false), undelegate(selector, name, false)", function() {
|
||||
|
@ -575,7 +617,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct
|
|||
|
||||
var main = 0;
|
||||
|
||||
jQuery("#main").delegate("#ap", "click", function(e){ main++; });
|
||||
jQuery("#qunit-fixture").delegate("#ap", "click", function(e){ main++; });
|
||||
jQuery("#ap").trigger("click");
|
||||
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||
|
||||
|
@ -588,7 +630,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct
|
|||
jQuery("#ap").undelegate("#groups", "click", false);
|
||||
jQuery("#groups").trigger("click");
|
||||
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||
jQuery("#main").undelegate("#ap", "click");
|
||||
jQuery("#qunit-fixture").undelegate("#ap", "click");
|
||||
});
|
||||
|
||||
test("bind()/trigger()/unbind() on plain object", function() {
|
||||
|
@ -738,6 +780,43 @@ test("mouseover triggers mouseenter", function() {
|
|||
elem.remove();
|
||||
});
|
||||
|
||||
test("withinElement implemented with jQuery.contains()", function() {
|
||||
|
||||
expect(1);
|
||||
|
||||
jQuery("#qunit-fixture").append('<div id="jc-outer"><div id="jc-inner"></div></div>');
|
||||
|
||||
jQuery("#jc-outer").bind("mouseenter mouseleave", function( event ) {
|
||||
|
||||
equal( this.id, "jc-outer", this.id + " " + event.type );
|
||||
|
||||
}).trigger("mouseenter");
|
||||
|
||||
jQuery("#jc-inner").trigger("mousenter");
|
||||
|
||||
jQuery("#jc-outer").unbind("mouseenter mouseleave").remove();
|
||||
jQuery("#jc-inner").remove();
|
||||
|
||||
});
|
||||
|
||||
test("mouseenter, mouseleave don't catch exceptions", function() {
|
||||
expect(2);
|
||||
|
||||
var elem = jQuery("#firstp").hover(function() { throw "an Exception"; });
|
||||
|
||||
try {
|
||||
elem.mouseenter();
|
||||
} catch (e) {
|
||||
equals( e, "an Exception", "mouseenter doesn't catch exceptions" );
|
||||
}
|
||||
|
||||
try {
|
||||
elem.mouseleave();
|
||||
} catch (e) {
|
||||
equals( e, "an Exception", "mouseleave doesn't catch exceptions" );
|
||||
}
|
||||
});
|
||||
|
||||
test("trigger() shortcuts", function() {
|
||||
expect(6);
|
||||
|
||||
|
@ -792,7 +871,7 @@ test("trigger() bubbling", function() {
|
|||
jQuery(document).bind("click", function(e){ if ( e.target !== document) { doc++; } });
|
||||
jQuery("html").bind("click", function(e){ html++; });
|
||||
jQuery("body").bind("click", function(e){ body++; });
|
||||
jQuery("#main").bind("click", function(e){ main++; });
|
||||
jQuery("#qunit-fixture").bind("click", function(e){ main++; });
|
||||
jQuery("#ap").bind("click", function(){ ap++; return false; });
|
||||
|
||||
jQuery("html").trigger("click");
|
||||
|
@ -806,7 +885,7 @@ test("trigger() bubbling", function() {
|
|||
equals( html, 2, "Body bubble" );
|
||||
equals( body, 1, "Body bubble" );
|
||||
|
||||
jQuery("#main").trigger("click");
|
||||
jQuery("#qunit-fixture").trigger("click");
|
||||
equals( win, 3, "Main bubble" );
|
||||
equals( doc, 3, "Main bubble" );
|
||||
equals( html, 3, "Main bubble" );
|
||||
|
@ -822,11 +901,11 @@ test("trigger() bubbling", function() {
|
|||
|
||||
// manually clean up events from elements outside the fixture
|
||||
jQuery(document).unbind("click");
|
||||
jQuery("html, body, #main").unbind("click");
|
||||
jQuery("html, body, #qunit-fixture").unbind("click");
|
||||
});
|
||||
|
||||
test("trigger(type, [data], [fn])", function() {
|
||||
expect(14);
|
||||
expect(16);
|
||||
|
||||
var handler = function(event, a, b, c) {
|
||||
equals( event.type, "click", "check passed data" );
|
||||
|
@ -843,7 +922,24 @@ test("trigger(type, [data], [fn])", function() {
|
|||
ok( true, "Native call was triggered" );
|
||||
};
|
||||
|
||||
// Triggers handlrs and native
|
||||
|
||||
$elem.live('mouseenter', function(){
|
||||
ok( true, 'Trigger mouseenter bound by live' );
|
||||
});
|
||||
|
||||
$elem.live('mouseleave', function(){
|
||||
ok( true, 'Trigger mouseleave bound by live' );
|
||||
});
|
||||
|
||||
$elem.trigger('mouseenter');
|
||||
|
||||
$elem.trigger('mouseleave');
|
||||
|
||||
$elem.die('mouseenter');
|
||||
|
||||
$elem.die('mouseleave');
|
||||
|
||||
// Triggers handlrs and native
|
||||
// Trigger 5
|
||||
$elem.bind("click", handler).trigger("click", [1, "2", "abc"]);
|
||||
|
||||
|
@ -866,7 +962,7 @@ test("trigger(type, [data], [fn])", function() {
|
|||
|
||||
pass = true;
|
||||
try {
|
||||
jQuery("#main table:first").bind("test:test", function(){}).trigger("test:test");
|
||||
jQuery("#qunit-fixture table:first").bind("test:test", function(){}).trigger("test:test");
|
||||
} catch (e) {
|
||||
pass = false;
|
||||
}
|
||||
|
@ -1183,11 +1279,11 @@ test(".live()/.die()", function() {
|
|||
jQuery("div").die("submit");
|
||||
|
||||
// Test binding with a different context
|
||||
var clicked = 0, container = jQuery("#main")[0];
|
||||
var clicked = 0, container = jQuery("#qunit-fixture")[0];
|
||||
jQuery("#foo", container).live("click", function(e){ clicked++; });
|
||||
jQuery("div").trigger("click");
|
||||
jQuery("#foo").trigger("click");
|
||||
jQuery("#main").trigger("click");
|
||||
jQuery("#qunit-fixture").trigger("click");
|
||||
jQuery("body").trigger("click");
|
||||
equals( clicked, 2, "live with a context" );
|
||||
|
||||
|
@ -1710,11 +1806,11 @@ test(".delegate()/.undelegate()", function() {
|
|||
jQuery("#body").undelegate("div", "submit");
|
||||
|
||||
// Test binding with a different context
|
||||
var clicked = 0, container = jQuery("#main")[0];
|
||||
jQuery("#main").delegate("#foo", "click", function(e){ clicked++; });
|
||||
var clicked = 0, container = jQuery("#qunit-fixture")[0];
|
||||
jQuery("#qunit-fixture").delegate("#foo", "click", function(e){ clicked++; });
|
||||
jQuery("div").trigger("click");
|
||||
jQuery("#foo").trigger("click");
|
||||
jQuery("#main").trigger("click");
|
||||
jQuery("#qunit-fixture").trigger("click");
|
||||
jQuery("body").trigger("click");
|
||||
equals( clicked, 2, "delegate with a context" );
|
||||
|
||||
|
@ -1722,7 +1818,7 @@ test(".delegate()/.undelegate()", function() {
|
|||
ok( jQuery._data(container, "events").live, "delegate with a context" );
|
||||
|
||||
// Test unbinding with a different context
|
||||
jQuery("#main").undelegate("#foo", "click");
|
||||
jQuery("#qunit-fixture").undelegate("#foo", "click");
|
||||
jQuery("#foo").trigger("click");
|
||||
equals( clicked, 2, "undelegate with a context");
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ test("unwrap()", function() {
|
|||
});
|
||||
|
||||
var testAppend = function(valueObj) {
|
||||
expect(37);
|
||||
expect(41);
|
||||
var defaultText = "Try them out:"
|
||||
var result = jQuery("#first").append(valueObj("<b>buga</b>"));
|
||||
equals( result.text(), defaultText + "buga", "Check if text appending works" );
|
||||
|
@ -330,6 +330,31 @@ var testAppend = function(valueObj) {
|
|||
d.contents().appendTo("#nonnodes");
|
||||
d.remove();
|
||||
ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );
|
||||
|
||||
QUnit.reset();
|
||||
var $input = jQuery("<input />").attr({ "type": "checkbox", "checked": true }).appendTo('#testForm');
|
||||
equals( $input[0].checked, true, "A checked checkbox that is appended stays checked" );
|
||||
|
||||
QUnit.reset();
|
||||
var $radios = jQuery("input:radio[name='R1']"),
|
||||
$radioNot = jQuery("<input type='radio' name='R1' checked='checked'/>").insertAfter( $radios ),
|
||||
$radio = $radios.eq(1).click();
|
||||
$radioNot[0].checked = false;
|
||||
$radios.parent().wrap("<div></div>");
|
||||
equals( $radio[0].checked, true, "Reappending radios uphold which radio is checked" );
|
||||
equals( $radioNot[0].checked, false, "Reappending radios uphold not being checked" );
|
||||
QUnit.reset();
|
||||
|
||||
var prev = jQuery("#sap").children().length;
|
||||
|
||||
jQuery("#sap").append(
|
||||
"<span></span>",
|
||||
"<span></span>",
|
||||
"<span></span>"
|
||||
);
|
||||
|
||||
equals( jQuery("#sap").children().length, prev + 3, "Make sure that multiple arguments works." );
|
||||
QUnit.reset();
|
||||
}
|
||||
|
||||
test("append(String|Element|Array<Element>|jQuery)", function() {
|
||||
|
@ -440,6 +465,40 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
|
|||
jQuery("#listWithTabIndex li.test6997").eq(1).click();
|
||||
});
|
||||
|
||||
test("append(xml)", function() {
|
||||
expect( 1 );
|
||||
|
||||
function createXMLDoc() {
|
||||
// Initialize DOM based upon latest installed MSXML or Netscape
|
||||
var elem,
|
||||
aActiveX =
|
||||
[ "MSXML6.DomDocument",
|
||||
"MSXML3.DomDocument",
|
||||
"MSXML2.DomDocument",
|
||||
"MSXML.DomDocument",
|
||||
"Microsoft.XmlDom" ];
|
||||
|
||||
if ( document.implementation && "createDocument" in document.implementation ) {
|
||||
return document.implementation.createDocument( "", "", null );
|
||||
} else {
|
||||
// IE
|
||||
for ( var n = 0, len = aActiveX.length; n < len; n++ ) {
|
||||
try {
|
||||
elem = new ActiveXObject( aActiveX[ n ] );
|
||||
return elem;
|
||||
} catch(_){};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var xmlDoc = createXMLDoc(),
|
||||
xml1 = xmlDoc.createElement("head"),
|
||||
xml2 = xmlDoc.createElement("test");
|
||||
|
||||
ok( jQuery( xml1 ).append( xml2 ), "Append an xml element to another without raising an exception." );
|
||||
|
||||
});
|
||||
|
||||
test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
||||
expect(16);
|
||||
|
||||
|
@ -483,19 +542,19 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
|||
var div = jQuery("<div/>").click(function(){
|
||||
ok(true, "Running a cloned click.");
|
||||
});
|
||||
div.appendTo("#main, #moretests");
|
||||
div.appendTo("#qunit-fixture, #moretests");
|
||||
|
||||
jQuery("#main div:last").click();
|
||||
jQuery("#qunit-fixture div:last").click();
|
||||
jQuery("#moretests div:last").click();
|
||||
|
||||
QUnit.reset();
|
||||
var div = jQuery("<div/>").appendTo("#main, #moretests");
|
||||
var div = jQuery("<div/>").appendTo("#qunit-fixture, #moretests");
|
||||
|
||||
equals( div.length, 2, "appendTo returns the inserted elements" );
|
||||
|
||||
div.addClass("test");
|
||||
|
||||
ok( jQuery("#main div:last").hasClass("test"), "appendTo element was modified after the insertion" );
|
||||
ok( jQuery("#qunit-fixture div:last").hasClass("test"), "appendTo element was modified after the insertion" );
|
||||
ok( jQuery("#moretests div:last").hasClass("test"), "appendTo element was modified after the insertion" );
|
||||
|
||||
QUnit.reset();
|
||||
|
@ -507,10 +566,10 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
|||
|
||||
div = jQuery("#moretests div");
|
||||
|
||||
var num = jQuery("#main div").length;
|
||||
div.remove().appendTo("#main");
|
||||
var num = jQuery("#qunit-fixture div").length;
|
||||
div.remove().appendTo("#qunit-fixture");
|
||||
|
||||
equals( jQuery("#main div").length, num, "Make sure all the removed divs were inserted." );
|
||||
equals( jQuery("#qunit-fixture div").length, num, "Make sure all the removed divs were inserted." );
|
||||
|
||||
QUnit.reset();
|
||||
});
|
||||
|
@ -750,7 +809,7 @@ var testReplaceWith = function(val) {
|
|||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after element" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("#main").append("<div id='bar'><div id='baz'</div></div>");
|
||||
jQuery("#qunit-fixture").append("<div id='bar'><div id='baz'</div></div>");
|
||||
jQuery("#baz").replaceWith("Baz");
|
||||
equals( jQuery("#bar").text(),"Baz", "Replace element with text" );
|
||||
ok( !jQuery("#baz")[0], "Verify that original element is gone, after element" );
|
||||
|
@ -813,14 +872,14 @@ var testReplaceWith = function(val) {
|
|||
|
||||
QUnit.reset();
|
||||
|
||||
jQuery("#main").append("<div id='replaceWith'></div>");
|
||||
equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
|
||||
jQuery("#qunit-fixture").append("<div id='replaceWith'></div>");
|
||||
equals( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
|
||||
|
||||
jQuery("#replaceWith").replaceWith( val("<div id='replaceWith'></div>") );
|
||||
equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
|
||||
equals( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
|
||||
|
||||
jQuery("#replaceWith").replaceWith( val("<div id='replaceWith'></div>") );
|
||||
equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
|
||||
equals( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
|
||||
}
|
||||
|
||||
test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
|
||||
|
@ -881,7 +940,7 @@ test("jQuery.clone() (#8017)", function() {
|
|||
|
||||
ok( jQuery.clone && jQuery.isFunction( jQuery.clone ) , "jQuery.clone() utility exists and is a function.");
|
||||
|
||||
var main = jQuery("#main")[0],
|
||||
var main = jQuery("#qunit-fixture")[0],
|
||||
clone = jQuery.clone( main );
|
||||
|
||||
equals( main.childNodes.length, clone.childNodes.length, "Simple child length to ensure a large dom tree copies correctly" );
|
||||
|
@ -890,7 +949,7 @@ test("jQuery.clone() (#8017)", function() {
|
|||
test("clone() (#8070)", function () {
|
||||
expect(2);
|
||||
|
||||
jQuery("<select class='test8070'></select><select class='test8070'></select>").appendTo("#main");
|
||||
jQuery("<select class='test8070'></select><select class='test8070'></select>").appendTo("#qunit-fixture");
|
||||
var selects = jQuery(".test8070");
|
||||
selects.append("<OPTION>1</OPTION><OPTION>2</OPTION>");
|
||||
|
||||
|
@ -1019,7 +1078,7 @@ test("clone(form element) (Bug #3879, #6655)", function() {
|
|||
|
||||
equals( clone.is(":checked"), element.is(":checked"), "Checked input cloned correctly" );
|
||||
equals( clone[0].defaultValue, "foo", "Checked input defaultValue cloned correctly" );
|
||||
|
||||
|
||||
// defaultChecked also gets set now due to setAttribute in attr, is this check still valid?
|
||||
// equals( clone[0].defaultChecked, !jQuery.support.noCloneChecked, "Checked input defaultChecked cloned correctly" );
|
||||
|
||||
|
@ -1062,7 +1121,7 @@ var testHtml = function(valueObj) {
|
|||
|
||||
jQuery.scriptorder = 0;
|
||||
|
||||
var div = jQuery("#main > div");
|
||||
var div = jQuery("#qunit-fixture > div");
|
||||
div.html(valueObj("<b>test</b>"));
|
||||
var pass = true;
|
||||
for ( var i = 0; i < div.size(); i++ ) {
|
||||
|
@ -1079,10 +1138,10 @@ var testHtml = function(valueObj) {
|
|||
ok( /^\xA0$|^ $/.test( space ), "Make sure entities are passed through correctly." );
|
||||
equals( jQuery("<div/>").html(valueObj("&"))[0].innerHTML, "&", "Make sure entities are passed through correctly." );
|
||||
|
||||
jQuery("#main").html(valueObj("<style>.foobar{color:green;}</style>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("<style>.foobar{color:green;}</style>"));
|
||||
|
||||
equals( jQuery("#main").children().length, 1, "Make sure there is a child element." );
|
||||
equals( jQuery("#main").children()[0].nodeName.toUpperCase(), "STYLE", "And that a style element was inserted." );
|
||||
equals( jQuery("#qunit-fixture").children().length, 1, "Make sure there is a child element." );
|
||||
equals( jQuery("#qunit-fixture").children()[0].nodeName.toUpperCase(), "STYLE", "And that a style element was inserted." );
|
||||
|
||||
QUnit.reset();
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
|
@ -1093,9 +1152,9 @@ var testHtml = function(valueObj) {
|
|||
j.find("b").removeData();
|
||||
equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
|
||||
|
||||
jQuery("#main").html(valueObj("<select/>"));
|
||||
jQuery("#main select").html(valueObj("<option>O1</option><option selected='selected'>O2</option><option>O3</option>"));
|
||||
equals( jQuery("#main select").val(), "O2", "Selected option correct" );
|
||||
jQuery("#qunit-fixture").html(valueObj("<select/>"));
|
||||
jQuery("#qunit-fixture select").html(valueObj("<option>O1</option><option selected='selected'>O2</option><option>O3</option>"));
|
||||
equals( jQuery("#qunit-fixture select").val(), "O2", "Selected option correct" );
|
||||
|
||||
var $div = jQuery("<div />");
|
||||
equals( $div.html(valueObj( 5 )).html(), "5", "Setting a number as html" );
|
||||
|
@ -1113,23 +1172,23 @@ var testHtml = function(valueObj) {
|
|||
|
||||
QUnit.reset();
|
||||
|
||||
jQuery("#main").html(valueObj("<script type='something/else'>ok( false, 'Non-script evaluated.' );</script><script type='text/javascript'>ok( true, 'text/javascript is evaluated.' );</script><script>ok( true, 'No type is evaluated.' );</script><div><script type='text/javascript'>ok( true, 'Inner text/javascript is evaluated.' );</script><script>ok( true, 'Inner No type is evaluated.' );</script><script type='something/else'>ok( false, 'Non-script evaluated.' );</script></div>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("<script type='something/else'>ok( false, 'Non-script evaluated.' );</script><script type='text/javascript'>ok( true, 'text/javascript is evaluated.' );</script><script>ok( true, 'No type is evaluated.' );</script><div><script type='text/javascript'>ok( true, 'Inner text/javascript is evaluated.' );</script><script>ok( true, 'Inner No type is evaluated.' );</script><script type='something/else'>ok( false, 'Non-script evaluated.' );</script></div>"));
|
||||
|
||||
var child = jQuery("#main").find("script");
|
||||
var child = jQuery("#qunit-fixture").find("script");
|
||||
|
||||
equals( child.length, 2, "Make sure that two non-JavaScript script tags are left." );
|
||||
equals( child[0].type, "something/else", "Verify type of script tag." );
|
||||
equals( child[1].type, "something/else", "Verify type of script tag." );
|
||||
|
||||
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
|
||||
jQuery("#main").html(valueObj("<script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (1)' );</script>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("<script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (1)' );</script>"));
|
||||
|
||||
jQuery("#main").html(valueObj("foo <form><script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (2)' );</script></form>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("foo <form><script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (2)' );</script></form>"));
|
||||
|
||||
jQuery("#main").html(valueObj("<script>equals(jQuery.scriptorder++, 0, 'Script is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(jQuery.scriptorder++, 1, 'Script (nested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(jQuery.scriptorder++, 2, 'Script (unnested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script>"));
|
||||
jQuery("#qunit-fixture").html(valueObj("<script>equals(jQuery.scriptorder++, 0, 'Script is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(jQuery.scriptorder++, 1, 'Script (nested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(jQuery.scriptorder++, 2, 'Script (unnested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script>"));
|
||||
}
|
||||
|
||||
test("html(String)", function() {
|
||||
|
@ -1143,18 +1202,18 @@ test("html(Function)", function() {
|
|||
|
||||
QUnit.reset();
|
||||
|
||||
jQuery("#main").html(function(){
|
||||
jQuery("#qunit-fixture").html(function(){
|
||||
return jQuery(this).text();
|
||||
});
|
||||
|
||||
ok( !/</.test( jQuery("#main").html() ), "Replace html with text." );
|
||||
ok( jQuery("#main").html().length > 0, "Make sure text exists." );
|
||||
ok( !/</.test( jQuery("#qunit-fixture").html() ), "Replace html with text." );
|
||||
ok( jQuery("#qunit-fixture").html().length > 0, "Make sure text exists." );
|
||||
});
|
||||
|
||||
test("html(Function) with incoming value", function() {
|
||||
expect(20);
|
||||
|
||||
var div = jQuery("#main > div"), old = div.map(function(){ return jQuery(this).html() });
|
||||
var div = jQuery("#qunit-fixture > div"), old = div.map(function(){ return jQuery(this).html() });
|
||||
|
||||
div.html(function(i, val) {
|
||||
equals( val, old[i], "Make sure the incoming value is correct." );
|
||||
|
@ -1251,7 +1310,7 @@ var testRemove = function(method) {
|
|||
|
||||
var count = 0;
|
||||
var first = jQuery("#ap").children(":first");
|
||||
var cleanUp = first.click(function() { count++ })[method]().appendTo("#main").click();
|
||||
var cleanUp = first.click(function() { count++ })[method]().appendTo("#qunit-fixture").click();
|
||||
|
||||
equals( method == "remove" ? 0 : 1, count );
|
||||
|
||||
|
@ -1359,7 +1418,7 @@ test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
|
|||
expect(1);
|
||||
|
||||
// DOM manipulation fails if added text matches an Object method
|
||||
var $f = jQuery( "<div />" ).appendTo( "#main" ),
|
||||
var $f = jQuery( "<div />" ).appendTo( "#qunit-fixture" ),
|
||||
bad = [ "start-", "toString", "hasOwnProperty", "append", "here&there!", "-end" ];
|
||||
|
||||
for ( var i=0; i < bad.length; i++ ) {
|
||||
|
@ -1368,6 +1427,41 @@ test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
|
|||
}
|
||||
catch(e) {}
|
||||
}
|
||||
equals($f.text(), bad.join(""), "Cached strings that match Object properties");
|
||||
equals($f.text(), bad.join(""), "Cached strings that match Object properties");
|
||||
$f.remove();
|
||||
});
|
||||
|
||||
test( "jQuery.html - execute scripts escaped with html comment or CDATA (#9221)", function() {
|
||||
expect( 3 );
|
||||
jQuery( [
|
||||
'<script type="text/javascript">',
|
||||
'<!--',
|
||||
'ok( true, "<!-- handled" );',
|
||||
'//-->',
|
||||
'</script>'
|
||||
].join ( "\n" ) ).appendTo( "#qunit-fixture" );
|
||||
jQuery( [
|
||||
'<script type="text/javascript">',
|
||||
'<![CDATA[',
|
||||
'ok( true, "<![CDATA[ handled" );',
|
||||
'//]]>',
|
||||
'</script>'
|
||||
].join ( "\n" ) ).appendTo( "#qunit-fixture" );
|
||||
jQuery( [
|
||||
'<script type="text/javascript">',
|
||||
'<!--//--><![CDATA[//><!--',
|
||||
'ok( true, "<!--//--><![CDATA[//><!-- (Drupal case) handled" );',
|
||||
'//--><!]]>',
|
||||
'</script>'
|
||||
].join ( "\n" ) ).appendTo( "#qunit-fixture" );
|
||||
});
|
||||
|
||||
test("jQuery.buildFragment - plain objects are not a document #8950", function() {
|
||||
expect(1);
|
||||
|
||||
try {
|
||||
jQuery('<input type="hidden">', {});
|
||||
ok( true, "Does not allow attribute object to be treated like a doc object");
|
||||
} catch (e) {}
|
||||
|
||||
});
|
||||
|
|
|
@ -107,7 +107,31 @@ test("queue() passes in the next item in the queue as a parameter to fx queues",
|
|||
equals(counter, 2, "Deferreds resolved");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test("callbacks keep their place in the queue", function() {
|
||||
expect(5);
|
||||
stop();
|
||||
var div = jQuery("<div>"),
|
||||
counter = 0;
|
||||
|
||||
div.queue(function( next ) {
|
||||
equal( ++counter, 1, "Queue/callback order: first called" );
|
||||
setTimeout( next, 200 );
|
||||
}).show(100, function() {
|
||||
equal( ++counter, 2, "Queue/callback order: second called" );
|
||||
jQuery(this).hide(100, function() {
|
||||
equal( ++counter, 4, "Queue/callback order: fourth called" );
|
||||
});
|
||||
}).queue(function( next ) {
|
||||
equal( ++counter, 3, "Queue/callback order: third called" );
|
||||
next();
|
||||
});
|
||||
|
||||
div.promise("fx").done(function() {
|
||||
equals(counter, 4, "Deferreds resolved");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test("delay()", function() {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
module("support", { teardown: moduleTeardown });
|
||||
|
||||
function supportIFrameTest( title, url, noDisplay, func ) {
|
||||
|
||||
if ( noDisplay !== true ) {
|
||||
func = noDisplay;
|
||||
noDisplay = false;
|
||||
}
|
||||
|
||||
test( title, function() {
|
||||
var iframe;
|
||||
|
||||
stop();
|
||||
window.supportCallback = function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
setTimeout( function() {
|
||||
window.supportCallback = undefined;
|
||||
iframe.remove();
|
||||
func.apply( self, args );
|
||||
start();
|
||||
}, 0 );
|
||||
};
|
||||
iframe = jQuery( "<div/>" ).css( "display", noDisplay ? "none" : "block" ).append(
|
||||
jQuery( "<iframe/>" ).attr( "src", "data/support/" + url + ".html" )
|
||||
).appendTo( "body" );
|
||||
});
|
||||
}
|
||||
|
||||
supportIFrameTest( "proper boxModel in compatMode CSS1Compat (IE6 and IE7)", "boxModelIE", function( compatMode, boxModel ) {
|
||||
ok( compatMode !== "CSS1Compat" || boxModel, "boxModel properly detected" );
|
||||
});
|
||||
|
||||
supportIFrameTest( "body background is not lost if set prior to loading jQuery (#9238)", "bodyBackground", function( color, support ) {
|
||||
expect( 2 );
|
||||
var okValue = {
|
||||
"#000000": true,
|
||||
"rgb(0, 0, 0)": true
|
||||
};
|
||||
ok( okValue[ color ], "color was not reset (" + color + ")" );
|
||||
var i, passed = true;
|
||||
for ( i in jQuery.support ) {
|
||||
if ( jQuery.support[ i ] !== support[ i ] ) {
|
||||
passed = false;
|
||||
strictEquals( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" );
|
||||
}
|
||||
}
|
||||
for ( i in support ) {
|
||||
if ( !( i in jQuery.support ) ) {
|
||||
ok = false;
|
||||
strictEquals( src[ i ], dest[ i ], "Unexpected property: " + i );
|
||||
}
|
||||
}
|
||||
ok( passed, "Same support properties" );
|
||||
});
|
|
@ -8,9 +8,9 @@ test("find(String)", function() {
|
|||
var j = jQuery("#nonnodes").contents();
|
||||
equals( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );
|
||||
|
||||
same( jQuery("#main").find("> div").get(), q("foo", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest"), "find child elements" );
|
||||
same( jQuery("#main").find("> #foo, > #moretests").get(), q("foo", "moretests"), "find child elements" );
|
||||
same( jQuery("#main").find("> #foo > p").get(), q("sndp", "en", "sap"), "find child elements" );
|
||||
same( jQuery("#qunit-fixture").find("> div").get(), q("foo", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest"), "find child elements" );
|
||||
same( jQuery("#qunit-fixture").find("> #foo, > #moretests").get(), q("foo", "moretests"), "find child elements" );
|
||||
same( jQuery("#qunit-fixture").find("> #foo > p").get(), q("sndp", "en", "sap"), "find child elements" );
|
||||
});
|
||||
|
||||
test("find(node|jQuery object)", function() {
|
||||
|
@ -155,9 +155,9 @@ test("filter(Selector|undefined)", function() {
|
|||
test("filter(Function)", function() {
|
||||
expect(2);
|
||||
|
||||
same( jQuery("#main p").filter(function() { return !jQuery("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );
|
||||
same( jQuery("#qunit-fixture p").filter(function() { return !jQuery("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );
|
||||
|
||||
same( jQuery("#main p").filter(function(i, elem) { return !jQuery("a", elem).length }).get(), q("sndp", "first"), "filter(Function) using arg" );
|
||||
same( jQuery("#qunit-fixture p").filter(function(i, elem) { return !jQuery("a", elem).length }).get(), q("sndp", "first"), "filter(Function) using arg" );
|
||||
});
|
||||
|
||||
test("filter(Element)", function() {
|
||||
|
@ -186,7 +186,7 @@ test("closest()", function() {
|
|||
same( jQuery("body").closest("body").get(), q("body"), "closest(body)" );
|
||||
same( jQuery("body").closest("html").get(), q("html"), "closest(html)" );
|
||||
same( jQuery("body").closest("div").get(), [], "closest(div)" );
|
||||
same( jQuery("#main").closest("span,#html").get(), q("html"), "closest(span,#html)" );
|
||||
same( jQuery("#qunit-fixture").closest("span,#html").get(), q("html"), "closest(span,#html)" );
|
||||
|
||||
same( jQuery("div:eq(1)").closest("div:first").get(), [], "closest(div:first)" );
|
||||
same( jQuery("div").closest("body:first div:last").get(), q("fx-tests"), "closest(body:first div:last)" );
|
||||
|
@ -198,7 +198,7 @@ test("closest()", function() {
|
|||
same( jq.closest("#nothiddendiv", document.body).get(), q("nothiddendiv"), "Context not reached." );
|
||||
|
||||
//Test that .closest() returns unique'd set
|
||||
equals( jQuery("#main p").closest("#main").length, 1, "Closest should return a unique set" );
|
||||
equals( jQuery("#qunit-fixture p").closest("#qunit-fixture").length, 1, "Closest should return a unique set" );
|
||||
|
||||
// Test on disconnected node
|
||||
equals( jQuery("<div><p></p></div>").find("p").closest("table").length, 0, "Make sure disconnected closest work." );
|
||||
|
@ -213,8 +213,8 @@ test("closest(Array)", function() {
|
|||
same( jQuery("body").closest(["body"]), [{selector:"body", elem:document.body, level:1}], "closest([body])" );
|
||||
same( jQuery("body").closest(["html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([html])" );
|
||||
same( jQuery("body").closest(["div"]), [], "closest([div])" );
|
||||
same( jQuery("#yahoo").closest(["div"]), [{"selector":"div", "elem": document.getElementById("foo"), "level": 3}, { "selector": "div", "elem": document.getElementById("main"), "level": 4 }], "closest([div])" );
|
||||
same( jQuery("#main").closest(["span,#html"]), [{selector:"span,#html", elem:document.documentElement, level:4}], "closest([span,#html])" );
|
||||
same( jQuery("#yahoo").closest(["div"]), [{"selector":"div", "elem": document.getElementById("foo"), "level": 3}, { "selector": "div", "elem": document.getElementById("qunit-fixture"), "level": 4 }], "closest([div])" );
|
||||
same( jQuery("#qunit-fixture").closest(["span,#html"]), [{selector:"span,#html", elem:document.documentElement, level:4}], "closest([span,#html])" );
|
||||
|
||||
same( jQuery("body").closest(["body","html"]), [{selector:"body", elem:document.body, level:1}, {selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" );
|
||||
same( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" );
|
||||
|
@ -224,7 +224,7 @@ test("closest(jQuery)", function() {
|
|||
expect(8);
|
||||
var $child = jQuery("#nothiddendivchild"),
|
||||
$parent = jQuery("#nothiddendiv"),
|
||||
$main = jQuery("#main"),
|
||||
$main = jQuery("#qunit-fixture"),
|
||||
$body = jQuery("body");
|
||||
ok( $child.closest( $parent ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') )" );
|
||||
ok( $child.closest( $parent[0] ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') ) :: node" );
|
||||
|
@ -238,7 +238,7 @@ test("closest(jQuery)", function() {
|
|||
|
||||
test("not(Selector|undefined)", function() {
|
||||
expect(11);
|
||||
equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" );
|
||||
equals( jQuery("#qunit-fixture > p#ap > a").not("#google").length, 2, "not('selector')" );
|
||||
same( jQuery("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );
|
||||
same( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
|
||||
same( jQuery("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d", "option3e", "option4e","option5b"), "not('complex selector')");
|
||||
|
@ -262,13 +262,13 @@ test("not(Element)", function() {
|
|||
});
|
||||
|
||||
test("not(Function)", function() {
|
||||
same( jQuery("#main p").not(function() { return jQuery("a", this).length }).get(), q("sndp", "first"), "not(Function)" );
|
||||
same( jQuery("#qunit-fixture p").not(function() { return jQuery("a", this).length }).get(), q("sndp", "first"), "not(Function)" );
|
||||
});
|
||||
|
||||
test("not(Array)", function() {
|
||||
expect(2);
|
||||
|
||||
equals( jQuery("#main > p#ap > a").not(document.getElementById("google")).length, 2, "not(DOMElement)" );
|
||||
equals( jQuery("#qunit-fixture > p#ap > a").not(document.getElementById("google")).length, 2, "not(DOMElement)" );
|
||||
equals( jQuery("p").not(document.getElementsByTagName("p")).length, 0, "not(Array-like DOM collection)" );
|
||||
});
|
||||
|
||||
|
@ -281,37 +281,37 @@ test("not(jQuery)", function() {
|
|||
test("has(Element)", function() {
|
||||
expect(2);
|
||||
|
||||
var obj = jQuery("#main").has(jQuery("#sndp")[0]);
|
||||
same( obj.get(), q("main"), "Keeps elements that have the element as a descendant" );
|
||||
var obj = jQuery("#qunit-fixture").has(jQuery("#sndp")[0]);
|
||||
same( obj.get(), q("qunit-fixture"), "Keeps elements that have the element as a descendant" );
|
||||
|
||||
var multipleParent = jQuery("#main, #header").has(jQuery("#sndp")[0]);
|
||||
same( obj.get(), q("main"), "Does not include elements that do not have the element as a descendant" );
|
||||
var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")[0]);
|
||||
same( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" );
|
||||
});
|
||||
|
||||
test("has(Selector)", function() {
|
||||
expect(3);
|
||||
|
||||
var obj = jQuery("#main").has("#sndp");
|
||||
same( obj.get(), q("main"), "Keeps elements that have any element matching the selector as a descendant" );
|
||||
var obj = jQuery("#qunit-fixture").has("#sndp");
|
||||
same( obj.get(), q("qunit-fixture"), "Keeps elements that have any element matching the selector as a descendant" );
|
||||
|
||||
var multipleParent = jQuery("#main, #header").has("#sndp");
|
||||
same( obj.get(), q("main"), "Does not include elements that do not have the element as a descendant" );
|
||||
var multipleParent = jQuery("#qunit-fixture, #header").has("#sndp");
|
||||
same( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" );
|
||||
|
||||
var multipleHas = jQuery("#main").has("#sndp, #first");
|
||||
same( multipleHas.get(), q("main"), "Only adds elements once" );
|
||||
var multipleHas = jQuery("#qunit-fixture").has("#sndp, #first");
|
||||
same( multipleHas.get(), q("qunit-fixture"), "Only adds elements once" );
|
||||
});
|
||||
|
||||
test("has(Arrayish)", function() {
|
||||
expect(3);
|
||||
|
||||
var simple = jQuery("#main").has(jQuery("#sndp"));
|
||||
same( simple.get(), q("main"), "Keeps elements that have any element in the jQuery list as a descendant" );
|
||||
var simple = jQuery("#qunit-fixture").has(jQuery("#sndp"));
|
||||
same( simple.get(), q("qunit-fixture"), "Keeps elements that have any element in the jQuery list as a descendant" );
|
||||
|
||||
var multipleParent = jQuery("#main, #header").has(jQuery("#sndp"));
|
||||
same( multipleParent.get(), q("main"), "Does not include elements that do not have an element in the jQuery list as a descendant" );
|
||||
var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp"));
|
||||
same( multipleParent.get(), q("qunit-fixture"), "Does not include elements that do not have an element in the jQuery list as a descendant" );
|
||||
|
||||
var multipleHas = jQuery("#main").has(jQuery("#sndp, #first"));
|
||||
same( simple.get(), q("main"), "Only adds elements once" );
|
||||
var multipleHas = jQuery("#qunit-fixture").has(jQuery("#sndp, #first"));
|
||||
same( simple.get(), q("qunit-fixture"), "Only adds elements once" );
|
||||
});
|
||||
|
||||
test("andSelf()", function() {
|
||||
|
@ -319,7 +319,7 @@ test("andSelf()", function() {
|
|||
same( jQuery("#en").siblings().andSelf().get(), q("sndp", "en", "sap"), "Check for siblings and self" );
|
||||
same( jQuery("#foo").children().andSelf().get(), q("foo", "sndp", "en", "sap"), "Check for children and self" );
|
||||
same( jQuery("#sndp, #en").parent().andSelf().get(), q("foo","sndp","en"), "Check for parent and self" );
|
||||
same( jQuery("#groups").parents("p, div").andSelf().get(), q("main", "ap", "groups"), "Check for parents and self" );
|
||||
same( jQuery("#groups").parents("p, div").andSelf().get(), q("qunit-fixture", "ap", "groups"), "Check for parents and self" );
|
||||
});
|
||||
|
||||
test("siblings([String])", function() {
|
||||
|
@ -352,9 +352,9 @@ test("parents([String])", function() {
|
|||
expect(5);
|
||||
equals( jQuery("#groups").parents()[0].id, "ap", "Simple parents check" );
|
||||
equals( jQuery("#groups").parents("p")[0].id, "ap", "Filtered parents check" );
|
||||
equals( jQuery("#groups").parents("div")[0].id, "main", "Filtered parents check2" );
|
||||
same( jQuery("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );
|
||||
same( jQuery("#en, #sndp").parents().get(), q("foo", "main", "dl", "body", "html"), "Check for unique results from parents" );
|
||||
equals( jQuery("#groups").parents("div")[0].id, "qunit-fixture", "Filtered parents check2" );
|
||||
same( jQuery("#groups").parents("p, div").get(), q("ap", "qunit-fixture"), "Check for multiple filters" );
|
||||
same( jQuery("#en, #sndp").parents().get(), q("foo", "qunit-fixture", "dl", "body", "html"), "Check for unique results from parents" );
|
||||
});
|
||||
|
||||
test("parentsUntil([String])", function() {
|
||||
|
@ -367,7 +367,7 @@ test("parentsUntil([String])", function() {
|
|||
same( jQuery("#groups").parentsUntil("#html").get(), parents.not(":last").get(), "Simple parentsUntil check" );
|
||||
equals( jQuery("#groups").parentsUntil("#ap").length, 0, "Simple parentsUntil check" );
|
||||
same( jQuery("#groups").parentsUntil("#html, #body").get(), parents.slice( 0, 3 ).get(), "Less simple parentsUntil check" );
|
||||
same( jQuery("#groups").parentsUntil("#html", "div").get(), jQuery("#main").get(), "Filtered parentsUntil check" );
|
||||
same( jQuery("#groups").parentsUntil("#html", "div").get(), jQuery("#qunit-fixture").get(), "Filtered parentsUntil check" );
|
||||
same( jQuery("#groups").parentsUntil("#html", "p,div,dl").get(), parents.slice( 0, 3 ).get(), "Multiple-filtered parentsUntil check" );
|
||||
equals( jQuery("#groups").parentsUntil("#html", "span").length, 0, "Filtered parentsUntil check, no match" );
|
||||
same( jQuery("#groups, #ap").parentsUntil("#html", "p,div,dl").get(), parents.slice( 0, 3 ).get(), "Multi-source, multiple-filtered parentsUntil check" );
|
||||
|
@ -483,7 +483,12 @@ test("add(String|Element|Array|undefined)", function() {
|
|||
expect(16);
|
||||
same( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
|
||||
same( jQuery("#sndp").add( jQuery("#en")[0] ).add( jQuery("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
|
||||
ok( jQuery([]).add(jQuery("#form")[0].elements).length >= 13, "Check elements from array" );
|
||||
|
||||
// We no longer support .add(form.elements), unfortunately.
|
||||
// There is no way, in browsers, to reliably determine the difference
|
||||
// between form.elements and form - and doing .add(form) and having it
|
||||
// add the form elements is way to unexpected, so this gets the boot.
|
||||
// ok( jQuery([]).add(jQuery("#form")[0].elements).length >= 13, "Check elements from array" );
|
||||
|
||||
// For the time being, we're discontinuing support for jQuery(form.elements) since it's ambiguous in IE
|
||||
// use jQuery([]).add(form.elements) instead.
|
||||
|
@ -519,7 +524,8 @@ test("add(String|Element|Array|undefined)", function() {
|
|||
var notDefined;
|
||||
equals( jQuery([]).add(notDefined).length, 0, "Check that undefined adds nothing" );
|
||||
|
||||
ok( jQuery([]).add( document.getElementById("form") ).length >= 13, "Add a form (adds the elements)" );
|
||||
equals( jQuery([]).add( document.getElementById("form") ).length, 1, "Add a form" );
|
||||
equals( jQuery([]).add( document.getElementById("select1") ).length, 1, "Add a select" );
|
||||
});
|
||||
|
||||
test("add(String, Context)", function() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.6b1
|
||||
1.6.3pre
|
Loading…
Reference in New Issue