guff-compass 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +21 -0
- data/.gitignore +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/demo/bower_components/jquery/.bower.json +21 -0
- data/demo/bower_components/jquery/.editorconfig +43 -0
- data/demo/bower_components/jquery/.gitattributes +2 -0
- data/demo/bower_components/jquery/.gitignore +14 -0
- data/demo/bower_components/jquery/.gitmodules +6 -0
- data/demo/bower_components/jquery/.jshintrc +17 -0
- data/demo/bower_components/jquery/.mailmap +94 -0
- data/demo/bower_components/jquery/AUTHORS.txt +170 -0
- data/demo/bower_components/jquery/CONTRIBUTING.md +216 -0
- data/demo/bower_components/jquery/Gruntfile.js +594 -0
- data/demo/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/demo/bower_components/jquery/README.md +398 -0
- data/demo/bower_components/jquery/bower.json +11 -0
- data/demo/bower_components/jquery/build/release-notes.js +59 -0
- data/demo/bower_components/jquery/build/release.js +316 -0
- data/demo/bower_components/jquery/component.json +15 -0
- data/demo/bower_components/jquery/composer.json +35 -0
- data/demo/bower_components/jquery/jquery-migrate.js +511 -0
- data/demo/bower_components/jquery/jquery-migrate.min.js +3 -0
- data/demo/bower_components/jquery/jquery.js +9789 -0
- data/demo/bower_components/jquery/jquery.min.js +6 -0
- data/demo/bower_components/jquery/jquery.min.map +1 -0
- data/demo/bower_components/jquery/package.json +38 -0
- data/demo/bower_components/jquery/speed/benchmark.js +15 -0
- data/demo/bower_components/jquery/speed/benchmarker.css +65 -0
- data/demo/bower_components/jquery/speed/benchmarker.js +181 -0
- data/demo/bower_components/jquery/speed/closest.html +39 -0
- data/demo/bower_components/jquery/speed/css.html +82 -0
- data/demo/bower_components/jquery/speed/event.html +58 -0
- data/demo/bower_components/jquery/speed/filter.html +183 -0
- data/demo/bower_components/jquery/speed/find.html +179 -0
- data/demo/bower_components/jquery/speed/index.html +72 -0
- data/demo/bower_components/jquery/speed/jquery-basis.js +6238 -0
- data/demo/bower_components/jquery/speed/slice.vs.concat.html +47 -0
- data/demo/bower_components/jquery/src/.jshintrc +27 -0
- data/demo/bower_components/jquery/src/ajax.js +855 -0
- data/demo/bower_components/jquery/src/ajax/jsonp.js +80 -0
- data/demo/bower_components/jquery/src/ajax/script.js +86 -0
- data/demo/bower_components/jquery/src/ajax/xhr.js +207 -0
- data/demo/bower_components/jquery/src/attributes.js +659 -0
- data/demo/bower_components/jquery/src/callbacks.js +197 -0
- data/demo/bower_components/jquery/src/core.js +981 -0
- data/demo/bower_components/jquery/src/css.js +661 -0
- data/demo/bower_components/jquery/src/data.js +336 -0
- data/demo/bower_components/jquery/src/deferred.js +141 -0
- data/demo/bower_components/jquery/src/deprecated.js +11 -0
- data/demo/bower_components/jquery/src/dimensions.js +41 -0
- data/demo/bower_components/jquery/src/effects.js +732 -0
- data/demo/bower_components/jquery/src/event-alias.js +32 -0
- data/demo/bower_components/jquery/src/event.js +995 -0
- data/demo/bower_components/jquery/src/exports.js +21 -0
- data/demo/bower_components/jquery/src/intro.js +20 -0
- data/demo/bower_components/jquery/src/manipulation.js +744 -0
- data/demo/bower_components/jquery/src/offset.js +169 -0
- data/demo/bower_components/jquery/src/outro.js +2 -0
- data/demo/bower_components/jquery/src/queue.js +146 -0
- data/demo/bower_components/jquery/src/serialize.js +99 -0
- data/demo/bower_components/jquery/src/sizzle-jquery.js +7 -0
- data/demo/bower_components/jquery/src/support.js +246 -0
- data/demo/bower_components/jquery/src/traversing.js +283 -0
- data/demo/bower_components/jquery/src/wrap.js +66 -0
- data/demo/bower_components/jquery/test/.jshintignore +3 -0
- data/demo/bower_components/jquery/test/.jshintrc +60 -0
- data/demo/bower_components/jquery/test/data/1x1.jpg +0 -0
- data/demo/bower_components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
- data/demo/bower_components/jquery/test/data/atom+xml.php +4 -0
- data/demo/bower_components/jquery/test/data/badcall.js +1 -0
- data/demo/bower_components/jquery/test/data/badjson.js +1 -0
- data/demo/bower_components/jquery/test/data/cleanScript.html +10 -0
- data/demo/bower_components/jquery/test/data/core/cc_on.html +22 -0
- data/demo/bower_components/jquery/test/data/dashboard.xml +11 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentLarge.html +17 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentSmall.html +21 -0
- data/demo/bower_components/jquery/test/data/echoData.php +1 -0
- data/demo/bower_components/jquery/test/data/echoQuery.php +1 -0
- data/demo/bower_components/jquery/test/data/errorWithJSON.php +6 -0
- data/demo/bower_components/jquery/test/data/errorWithText.php +5 -0
- data/demo/bower_components/jquery/test/data/etag.php +21 -0
- data/demo/bower_components/jquery/test/data/evalScript.php +1 -0
- data/demo/bower_components/jquery/test/data/event/focusElem.html +16 -0
- data/demo/bower_components/jquery/test/data/event/longLoadScript.php +4 -0
- data/demo/bower_components/jquery/test/data/event/promiseReady.html +17 -0
- data/demo/bower_components/jquery/test/data/event/syncReady.html +23 -0
- data/demo/bower_components/jquery/test/data/headers.php +18 -0
- data/demo/bower_components/jquery/test/data/if_modified_since.php +20 -0
- data/demo/bower_components/jquery/test/data/iframe.html +8 -0
- data/demo/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js +5 -0
- data/demo/bower_components/jquery/test/data/json.php +13 -0
- data/demo/bower_components/jquery/test/data/json_obj.js +1 -0
- data/demo/bower_components/jquery/test/data/jsonp.php +14 -0
- data/demo/bower_components/jquery/test/data/manipulation/iframe-denied.html +36 -0
- data/demo/bower_components/jquery/test/data/name.html +1 -0
- data/demo/bower_components/jquery/test/data/name.php +24 -0
- data/demo/bower_components/jquery/test/data/nocontent.php +5 -0
- data/demo/bower_components/jquery/test/data/offset/absolute.html +41 -0
- data/demo/bower_components/jquery/test/data/offset/body.html +26 -0
- data/demo/bower_components/jquery/test/data/offset/fixed.html +34 -0
- data/demo/bower_components/jquery/test/data/offset/relative.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/scroll.html +39 -0
- data/demo/bower_components/jquery/test/data/offset/static.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/table.html +43 -0
- data/demo/bower_components/jquery/test/data/params_html.php +12 -0
- data/demo/bower_components/jquery/test/data/readywaitasset.js +1 -0
- data/demo/bower_components/jquery/test/data/readywaitloader.js +25 -0
- data/demo/bower_components/jquery/test/data/script.php +11 -0
- data/demo/bower_components/jquery/test/data/selector/html5_selector.html +114 -0
- data/demo/bower_components/jquery/test/data/selector/sizzle_cache.html +21 -0
- data/demo/bower_components/jquery/test/data/statusText.php +5 -0
- data/demo/bower_components/jquery/test/data/support/bodyBackground.html +28 -0
- data/demo/bower_components/jquery/test/data/support/boxSizing.html +19 -0
- data/demo/bower_components/jquery/test/data/support/csp.js +3 -0
- data/demo/bower_components/jquery/test/data/support/csp.php +22 -0
- data/demo/bower_components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
- data/demo/bower_components/jquery/test/data/support/testElementCrash.html +17 -0
- data/demo/bower_components/jquery/test/data/test.html +7 -0
- data/demo/bower_components/jquery/test/data/test.js +3 -0
- data/demo/bower_components/jquery/test/data/test.php +7 -0
- data/demo/bower_components/jquery/test/data/test2.html +5 -0
- data/demo/bower_components/jquery/test/data/test3.html +3 -0
- data/demo/bower_components/jquery/test/data/testinit.js +264 -0
- data/demo/bower_components/jquery/test/data/testrunner.js +371 -0
- data/demo/bower_components/jquery/test/data/testsuite.css +155 -0
- data/demo/bower_components/jquery/test/data/text.php +12 -0
- data/demo/bower_components/jquery/test/data/ua.txt +272 -0
- data/demo/bower_components/jquery/test/data/with_fries.xml +25 -0
- data/demo/bower_components/jquery/test/data/with_fries_over_jsonp.php +7 -0
- data/demo/bower_components/jquery/test/delegatetest.html +228 -0
- data/demo/bower_components/jquery/test/hovertest.html +158 -0
- data/demo/bower_components/jquery/test/index.html +337 -0
- data/demo/bower_components/jquery/test/jquery.js +5 -0
- data/demo/bower_components/jquery/test/localfile.html +75 -0
- data/demo/bower_components/jquery/test/networkerror.html +84 -0
- data/demo/bower_components/jquery/test/readywait.html +70 -0
- data/demo/bower_components/jquery/test/unit/ajax.js +2016 -0
- data/demo/bower_components/jquery/test/unit/attributes.js +1388 -0
- data/demo/bower_components/jquery/test/unit/callbacks.js +342 -0
- data/demo/bower_components/jquery/test/unit/core.js +1360 -0
- data/demo/bower_components/jquery/test/unit/css.js +1056 -0
- data/demo/bower_components/jquery/test/unit/data.js +645 -0
- data/demo/bower_components/jquery/test/unit/deferred.js +436 -0
- data/demo/bower_components/jquery/test/unit/deprecated.js +8 -0
- data/demo/bower_components/jquery/test/unit/dimensions.js +472 -0
- data/demo/bower_components/jquery/test/unit/effects.js +2242 -0
- data/demo/bower_components/jquery/test/unit/event.js +2755 -0
- data/demo/bower_components/jquery/test/unit/exports.js +7 -0
- data/demo/bower_components/jquery/test/unit/manipulation.js +2120 -0
- data/demo/bower_components/jquery/test/unit/offset.js +559 -0
- data/demo/bower_components/jquery/test/unit/queue.js +314 -0
- data/demo/bower_components/jquery/test/unit/selector.js +172 -0
- data/demo/bower_components/jquery/test/unit/serialize.js +148 -0
- data/demo/bower_components/jquery/test/unit/support.js +370 -0
- data/demo/bower_components/jquery/test/unit/traversing.js +797 -0
- data/demo/bower_components/jquery/test/unit/wrap.js +265 -0
- data/demo/bower_components/jquery/test/xhtml.php +5 -0
- data/demo/index.html +347 -0
- data/demo/styles/main.css +208 -0
- data/demo/styles/main.scss +138 -0
- data/docs/docco.css +506 -0
- data/docs/guff.html +1127 -0
- data/docs/public/fonts/aller-bold.eot +0 -0
- data/docs/public/fonts/aller-bold.ttf +0 -0
- data/docs/public/fonts/aller-bold.woff +0 -0
- data/docs/public/fonts/aller-light.eot +0 -0
- data/docs/public/fonts/aller-light.ttf +0 -0
- data/docs/public/fonts/aller-light.woff +0 -0
- data/docs/public/fonts/novecento-bold.eot +0 -0
- data/docs/public/fonts/novecento-bold.ttf +0 -0
- data/docs/public/fonts/novecento-bold.woff +0 -0
- data/docs/public/stylesheets/normalize.css +375 -0
- data/guff.gemspec +16 -0
- data/guff.scss +514 -0
- data/gulpfile.js +67 -0
- data/lib/guff.rb +4 -0
- data/lib/stylesheets/_guff.scss +514 -0
- data/package.json +19 -0
- data/src/_functions.scss +57 -0
- data/src/_mixins.scss +301 -0
- data/src/_reset.scss +67 -0
- data/src/_settings.scss +22 -0
- data/src/_typography.scss +67 -0
- metadata +259 -0
@@ -0,0 +1,436 @@
|
|
1
|
+
module( "deferred", {
|
2
|
+
teardown: moduleTeardown
|
3
|
+
});
|
4
|
+
|
5
|
+
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
6
|
+
|
7
|
+
function createDeferred( fn ) {
|
8
|
+
return withNew ? new jQuery.Deferred( fn ) : jQuery.Deferred( fn );
|
9
|
+
}
|
10
|
+
|
11
|
+
test( "jQuery.Deferred" + withNew, function() {
|
12
|
+
|
13
|
+
expect( 23 );
|
14
|
+
|
15
|
+
var defer = createDeferred();
|
16
|
+
|
17
|
+
strictEqual( defer.pipe, defer.then, "pipe is an alias of then" );
|
18
|
+
|
19
|
+
createDeferred().resolve().done(function() {
|
20
|
+
ok( true, "Success on resolve" );
|
21
|
+
strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
|
22
|
+
}).fail(function() {
|
23
|
+
ok( false, "Error on resolve" );
|
24
|
+
}).always(function() {
|
25
|
+
ok( true, "Always callback on resolve" );
|
26
|
+
});
|
27
|
+
|
28
|
+
createDeferred().reject().done(function() {
|
29
|
+
ok( false, "Success on reject" );
|
30
|
+
}).fail(function() {
|
31
|
+
ok( true, "Error on reject" );
|
32
|
+
strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
|
33
|
+
}).always(function() {
|
34
|
+
ok( true, "Always callback on reject" );
|
35
|
+
});
|
36
|
+
|
37
|
+
createDeferred(function( defer ) {
|
38
|
+
ok( this === defer, "Defer passed as this & first argument" );
|
39
|
+
this.resolve("done");
|
40
|
+
}).done(function( value ) {
|
41
|
+
strictEqual( value, "done", "Passed function executed" );
|
42
|
+
});
|
43
|
+
|
44
|
+
createDeferred(function( defer ) {
|
45
|
+
var promise = defer.promise(),
|
46
|
+
func = function() {},
|
47
|
+
funcPromise = defer.promise( func );
|
48
|
+
strictEqual( defer.promise(), promise, "promise is always the same" );
|
49
|
+
strictEqual( funcPromise, func, "non objects get extended" );
|
50
|
+
jQuery.each( promise, function( key ) {
|
51
|
+
if ( !jQuery.isFunction( promise[ key ] ) ) {
|
52
|
+
ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" );
|
53
|
+
}
|
54
|
+
if ( promise[ key ] !== func[ key ] ) {
|
55
|
+
strictEqual( func[ key ], promise[ key ], key + " is the same" );
|
56
|
+
}
|
57
|
+
});
|
58
|
+
});
|
59
|
+
|
60
|
+
jQuery.expandedEach = jQuery.each;
|
61
|
+
jQuery.expandedEach( "resolve reject".split(" "), function( _, change ) {
|
62
|
+
createDeferred(function( defer ) {
|
63
|
+
strictEqual( defer.state(), "pending", "pending after creation" );
|
64
|
+
var checked = 0;
|
65
|
+
defer.progress(function( value ) {
|
66
|
+
strictEqual( value, checked, "Progress: right value (" + value + ") received" );
|
67
|
+
});
|
68
|
+
for ( checked = 0; checked < 3; checked++ ) {
|
69
|
+
defer.notify( checked );
|
70
|
+
}
|
71
|
+
strictEqual( defer.state(), "pending", "pending after notification" );
|
72
|
+
defer[ change ]();
|
73
|
+
notStrictEqual( defer.state(), "pending", "not pending after " + change );
|
74
|
+
defer.notify();
|
75
|
+
});
|
76
|
+
});
|
77
|
+
});
|
78
|
+
});
|
79
|
+
|
80
|
+
|
81
|
+
test( "jQuery.Deferred - chainability", function() {
|
82
|
+
|
83
|
+
var defer = jQuery.Deferred();
|
84
|
+
|
85
|
+
expect( 10 );
|
86
|
+
|
87
|
+
jQuery.expandedEach = jQuery.each;
|
88
|
+
jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split(" "), function( _, method ) {
|
89
|
+
var object = {
|
90
|
+
m: defer[ method ]
|
91
|
+
};
|
92
|
+
strictEqual( object.m(), object, method + " is chainable" );
|
93
|
+
});
|
94
|
+
});
|
95
|
+
|
96
|
+
test( "jQuery.Deferred.then - filtering (done)", function() {
|
97
|
+
|
98
|
+
expect( 4 );
|
99
|
+
|
100
|
+
var value1, value2, value3,
|
101
|
+
defer = jQuery.Deferred(),
|
102
|
+
piped = defer.then(function( a, b ) {
|
103
|
+
return a * b;
|
104
|
+
});
|
105
|
+
|
106
|
+
piped.done(function( result ) {
|
107
|
+
value3 = result;
|
108
|
+
});
|
109
|
+
|
110
|
+
defer.done(function( a, b ) {
|
111
|
+
value1 = a;
|
112
|
+
value2 = b;
|
113
|
+
});
|
114
|
+
|
115
|
+
defer.resolve( 2, 3 );
|
116
|
+
|
117
|
+
strictEqual( value1, 2, "first resolve value ok" );
|
118
|
+
strictEqual( value2, 3, "second resolve value ok" );
|
119
|
+
strictEqual( value3, 6, "result of filter ok" );
|
120
|
+
|
121
|
+
jQuery.Deferred().reject().then(function() {
|
122
|
+
ok( false, "then should not be called on reject" );
|
123
|
+
});
|
124
|
+
|
125
|
+
jQuery.Deferred().resolve().then( jQuery.noop ).done(function( value ) {
|
126
|
+
strictEqual( value, undefined, "then done callback can return undefined/null" );
|
127
|
+
});
|
128
|
+
});
|
129
|
+
|
130
|
+
test( "jQuery.Deferred.then - filtering (fail)", function() {
|
131
|
+
|
132
|
+
expect( 4 );
|
133
|
+
|
134
|
+
var value1, value2, value3,
|
135
|
+
defer = jQuery.Deferred(),
|
136
|
+
piped = defer.then( null, function( a, b ) {
|
137
|
+
return a * b;
|
138
|
+
});
|
139
|
+
|
140
|
+
piped.fail(function( result ) {
|
141
|
+
value3 = result;
|
142
|
+
});
|
143
|
+
|
144
|
+
defer.fail(function( a, b ) {
|
145
|
+
value1 = a;
|
146
|
+
value2 = b;
|
147
|
+
});
|
148
|
+
|
149
|
+
defer.reject( 2, 3 );
|
150
|
+
|
151
|
+
strictEqual( value1, 2, "first reject value ok" );
|
152
|
+
strictEqual( value2, 3, "second reject value ok" );
|
153
|
+
strictEqual( value3, 6, "result of filter ok" );
|
154
|
+
|
155
|
+
jQuery.Deferred().resolve().then( null, function() {
|
156
|
+
ok( false, "then should not be called on resolve" );
|
157
|
+
});
|
158
|
+
|
159
|
+
jQuery.Deferred().reject().then( null, jQuery.noop ).fail(function( value ) {
|
160
|
+
strictEqual( value, undefined, "then fail callback can return undefined/null" );
|
161
|
+
});
|
162
|
+
});
|
163
|
+
|
164
|
+
test( "jQuery.Deferred.then - filtering (progress)", function() {
|
165
|
+
|
166
|
+
expect( 3 );
|
167
|
+
|
168
|
+
var value1, value2, value3,
|
169
|
+
defer = jQuery.Deferred(),
|
170
|
+
piped = defer.then( null, null, function( a, b ) {
|
171
|
+
return a * b;
|
172
|
+
});
|
173
|
+
|
174
|
+
piped.progress(function( result ) {
|
175
|
+
value3 = result;
|
176
|
+
});
|
177
|
+
|
178
|
+
defer.progress(function( a, b ) {
|
179
|
+
value1 = a;
|
180
|
+
value2 = b;
|
181
|
+
});
|
182
|
+
|
183
|
+
defer.notify( 2, 3 );
|
184
|
+
|
185
|
+
strictEqual( value1, 2, "first progress value ok" );
|
186
|
+
strictEqual( value2, 3, "second progress value ok" );
|
187
|
+
strictEqual( value3, 6, "result of filter ok" );
|
188
|
+
});
|
189
|
+
|
190
|
+
test( "jQuery.Deferred.then - deferred (done)", function() {
|
191
|
+
|
192
|
+
expect( 3 );
|
193
|
+
|
194
|
+
var value1, value2, value3,
|
195
|
+
defer = jQuery.Deferred(),
|
196
|
+
piped = defer.then(function( a, b ) {
|
197
|
+
return jQuery.Deferred(function( defer ) {
|
198
|
+
defer.reject( a * b );
|
199
|
+
});
|
200
|
+
});
|
201
|
+
|
202
|
+
piped.fail(function( result ) {
|
203
|
+
value3 = result;
|
204
|
+
});
|
205
|
+
|
206
|
+
defer.done(function( a, b ) {
|
207
|
+
value1 = a;
|
208
|
+
value2 = b;
|
209
|
+
});
|
210
|
+
|
211
|
+
defer.resolve( 2, 3 );
|
212
|
+
|
213
|
+
strictEqual( value1, 2, "first resolve value ok" );
|
214
|
+
strictEqual( value2, 3, "second resolve value ok" );
|
215
|
+
strictEqual( value3, 6, "result of filter ok" );
|
216
|
+
});
|
217
|
+
|
218
|
+
test( "jQuery.Deferred.then - deferred (fail)", function() {
|
219
|
+
|
220
|
+
expect( 3 );
|
221
|
+
|
222
|
+
var value1, value2, value3,
|
223
|
+
defer = jQuery.Deferred(),
|
224
|
+
piped = defer.then( null, function( a, b ) {
|
225
|
+
return jQuery.Deferred(function( defer ) {
|
226
|
+
defer.resolve( a * b );
|
227
|
+
});
|
228
|
+
});
|
229
|
+
|
230
|
+
piped.done(function( result ) {
|
231
|
+
value3 = result;
|
232
|
+
});
|
233
|
+
|
234
|
+
defer.fail(function( a, b ) {
|
235
|
+
value1 = a;
|
236
|
+
value2 = b;
|
237
|
+
});
|
238
|
+
|
239
|
+
defer.reject( 2, 3 );
|
240
|
+
|
241
|
+
strictEqual( value1, 2, "first reject value ok" );
|
242
|
+
strictEqual( value2, 3, "second reject value ok" );
|
243
|
+
strictEqual( value3, 6, "result of filter ok" );
|
244
|
+
});
|
245
|
+
|
246
|
+
test( "jQuery.Deferred.then - deferred (progress)", function() {
|
247
|
+
|
248
|
+
expect( 3 );
|
249
|
+
|
250
|
+
var value1, value2, value3,
|
251
|
+
defer = jQuery.Deferred(),
|
252
|
+
piped = defer.then( null, null, function( a, b ) {
|
253
|
+
return jQuery.Deferred(function( defer ) {
|
254
|
+
defer.resolve( a * b );
|
255
|
+
});
|
256
|
+
});
|
257
|
+
|
258
|
+
piped.done(function( result ) {
|
259
|
+
value3 = result;
|
260
|
+
});
|
261
|
+
|
262
|
+
defer.progress(function( a, b ) {
|
263
|
+
value1 = a;
|
264
|
+
value2 = b;
|
265
|
+
});
|
266
|
+
|
267
|
+
defer.notify( 2, 3 );
|
268
|
+
|
269
|
+
strictEqual( value1, 2, "first progress value ok" );
|
270
|
+
strictEqual( value2, 3, "second progress value ok" );
|
271
|
+
strictEqual( value3, 6, "result of filter ok" );
|
272
|
+
});
|
273
|
+
|
274
|
+
test( "jQuery.Deferred.then - context", function() {
|
275
|
+
|
276
|
+
expect( 7 );
|
277
|
+
|
278
|
+
var defer, piped, defer2, piped2,
|
279
|
+
context = {};
|
280
|
+
|
281
|
+
jQuery.Deferred().resolveWith( context, [ 2 ] ).then(function( value ) {
|
282
|
+
return value * 3;
|
283
|
+
}).done(function( value ) {
|
284
|
+
strictEqual( this, context, "custom context correctly propagated" );
|
285
|
+
strictEqual( value, 6, "proper value received" );
|
286
|
+
});
|
287
|
+
|
288
|
+
jQuery.Deferred().resolve().then(function() {
|
289
|
+
return jQuery.Deferred().resolveWith(context);
|
290
|
+
}).done(function() {
|
291
|
+
strictEqual( this, context, "custom context of returned deferred correctly propagated" );
|
292
|
+
});
|
293
|
+
|
294
|
+
defer = jQuery.Deferred();
|
295
|
+
piped = defer.then(function( value ) {
|
296
|
+
return value * 3;
|
297
|
+
});
|
298
|
+
|
299
|
+
defer.resolve( 2 );
|
300
|
+
|
301
|
+
piped.done(function( value ) {
|
302
|
+
strictEqual( this, piped, "default context gets updated to latest promise in the chain" );
|
303
|
+
strictEqual( value, 6, "proper value received" );
|
304
|
+
});
|
305
|
+
|
306
|
+
defer2 = jQuery.Deferred();
|
307
|
+
piped2 = defer2.then();
|
308
|
+
|
309
|
+
defer2.resolve( 2 );
|
310
|
+
|
311
|
+
piped2.done(function( value ) {
|
312
|
+
strictEqual( this, piped2, "default context gets updated to latest promise in the chain (without passing function)" );
|
313
|
+
strictEqual( value, 2, "proper value received (without passing function)" );
|
314
|
+
});
|
315
|
+
});
|
316
|
+
|
317
|
+
test( "jQuery.when", function() {
|
318
|
+
|
319
|
+
expect( 34 );
|
320
|
+
|
321
|
+
// Some other objects
|
322
|
+
jQuery.each({
|
323
|
+
"an empty string": "",
|
324
|
+
"a non-empty string": "some string",
|
325
|
+
"zero": 0,
|
326
|
+
"a number other than zero": 1,
|
327
|
+
"true": true,
|
328
|
+
"false": false,
|
329
|
+
"null": null,
|
330
|
+
"undefined": undefined,
|
331
|
+
"a plain object": {}
|
332
|
+
}, function( message, value ) {
|
333
|
+
ok(
|
334
|
+
jQuery.isFunction(
|
335
|
+
jQuery.when( value ).done(function( resolveValue ) {
|
336
|
+
strictEqual( this, window, "Context is the global object with " + message );
|
337
|
+
strictEqual( resolveValue, value, "Test the promise was resolved with " + message );
|
338
|
+
}).promise
|
339
|
+
),
|
340
|
+
"Test " + message + " triggers the creation of a new Promise"
|
341
|
+
);
|
342
|
+
});
|
343
|
+
|
344
|
+
ok(
|
345
|
+
jQuery.isFunction(
|
346
|
+
jQuery.when().done(function( resolveValue ) {
|
347
|
+
strictEqual( this, window, "Test the promise was resolved with window as its context" );
|
348
|
+
strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" );
|
349
|
+
}).promise
|
350
|
+
),
|
351
|
+
"Test calling when with no parameter triggers the creation of a new Promise"
|
352
|
+
);
|
353
|
+
|
354
|
+
var cache,
|
355
|
+
context = {};
|
356
|
+
|
357
|
+
jQuery.when( jQuery.Deferred().resolveWith( context ) ).done(function() {
|
358
|
+
strictEqual( this, context, "when( promise ) propagates context" );
|
359
|
+
});
|
360
|
+
|
361
|
+
jQuery.each([ 1, 2, 3 ], function( k, i ) {
|
362
|
+
|
363
|
+
jQuery.when( cache || jQuery.Deferred(function() {
|
364
|
+
this.resolve( i );
|
365
|
+
})
|
366
|
+
).done(function( value ) {
|
367
|
+
|
368
|
+
strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) );
|
369
|
+
cache = value;
|
370
|
+
});
|
371
|
+
|
372
|
+
});
|
373
|
+
});
|
374
|
+
|
375
|
+
test( "jQuery.when - joined", function() {
|
376
|
+
|
377
|
+
expect( 119 );
|
378
|
+
|
379
|
+
var deferreds = {
|
380
|
+
value: 1,
|
381
|
+
success: jQuery.Deferred().resolve( 1 ),
|
382
|
+
error: jQuery.Deferred().reject( 0 ),
|
383
|
+
futureSuccess: jQuery.Deferred().notify( true ),
|
384
|
+
futureError: jQuery.Deferred().notify( true ),
|
385
|
+
notify: jQuery.Deferred().notify( true )
|
386
|
+
},
|
387
|
+
willSucceed = {
|
388
|
+
value: true,
|
389
|
+
success: true,
|
390
|
+
futureSuccess: true
|
391
|
+
},
|
392
|
+
willError = {
|
393
|
+
error: true,
|
394
|
+
futureError: true
|
395
|
+
},
|
396
|
+
willNotify = {
|
397
|
+
futureSuccess: true,
|
398
|
+
futureError: true,
|
399
|
+
notify: true
|
400
|
+
};
|
401
|
+
|
402
|
+
jQuery.each( deferreds, function( id1, defer1 ) {
|
403
|
+
jQuery.each( deferreds, function( id2, defer2 ) {
|
404
|
+
var shouldResolve = willSucceed[ id1 ] && willSucceed[ id2 ],
|
405
|
+
shouldError = willError[ id1 ] || willError[ id2 ],
|
406
|
+
shouldNotify = willNotify[ id1 ] || willNotify[ id2 ],
|
407
|
+
expected = shouldResolve ? [ 1, 1 ] : [ 0, undefined ],
|
408
|
+
expectedNotify = shouldNotify && [ willNotify[ id1 ], willNotify[ id2 ] ],
|
409
|
+
code = id1 + "/" + id2,
|
410
|
+
context1 = defer1 && jQuery.isFunction( defer1.promise ) ? defer1.promise() : undefined,
|
411
|
+
context2 = defer2 && jQuery.isFunction( defer2.promise ) ? defer2.promise() : undefined;
|
412
|
+
|
413
|
+
jQuery.when( defer1, defer2 ).done(function( a, b ) {
|
414
|
+
if ( shouldResolve ) {
|
415
|
+
deepEqual( [ a, b ], expected, code + " => resolve" );
|
416
|
+
strictEqual( this[ 0 ], context1, code + " => first context OK" );
|
417
|
+
strictEqual( this[ 1 ], context2, code + " => second context OK" );
|
418
|
+
} else {
|
419
|
+
ok( false, code + " => resolve" );
|
420
|
+
}
|
421
|
+
}).fail(function( a, b ) {
|
422
|
+
if ( shouldError ) {
|
423
|
+
deepEqual( [ a, b ], expected, code + " => reject" );
|
424
|
+
} else {
|
425
|
+
ok( false, code + " => reject" );
|
426
|
+
}
|
427
|
+
}).progress(function( a, b ) {
|
428
|
+
deepEqual( [ a, b ], expectedNotify, code + " => progress" );
|
429
|
+
strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" );
|
430
|
+
strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" );
|
431
|
+
});
|
432
|
+
});
|
433
|
+
});
|
434
|
+
deferreds.futureSuccess.resolve( 1 );
|
435
|
+
deferreds.futureError.reject( 0 );
|
436
|
+
});
|
@@ -0,0 +1,472 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
if ( !jQuery.fn.width ) {
|
4
|
+
return;
|
5
|
+
}
|
6
|
+
|
7
|
+
module("dimensions", { teardown: moduleTeardown });
|
8
|
+
|
9
|
+
function pass( val ) {
|
10
|
+
return val;
|
11
|
+
}
|
12
|
+
|
13
|
+
function fn( val ) {
|
14
|
+
return function() {
|
15
|
+
return val;
|
16
|
+
};
|
17
|
+
}
|
18
|
+
|
19
|
+
/*
|
20
|
+
======== local reference =======
|
21
|
+
pass and fn can be used to test passing functions to setters
|
22
|
+
See testWidth below for an example
|
23
|
+
|
24
|
+
pass( value );
|
25
|
+
This function returns whatever value is passed in
|
26
|
+
|
27
|
+
fn( value );
|
28
|
+
Returns a function that returns the value
|
29
|
+
*/
|
30
|
+
|
31
|
+
function testWidth( val ) {
|
32
|
+
expect(9);
|
33
|
+
var $div, blah;
|
34
|
+
|
35
|
+
$div = jQuery("#nothiddendiv");
|
36
|
+
$div.width( val(30) );
|
37
|
+
equal($div.width(), 30, "Test set to 30 correctly");
|
38
|
+
$div.hide();
|
39
|
+
equal($div.width(), 30, "Test hidden div");
|
40
|
+
$div.show();
|
41
|
+
$div.width( val(-1) ); // handle negative numbers by setting to 0 #11604
|
42
|
+
equal($div.width(), 0, "Test negative width normalized to 0");
|
43
|
+
$div.css("padding", "20px");
|
44
|
+
equal($div.width(), 0, "Test padding specified with pixels");
|
45
|
+
$div.css("border", "2px solid #fff");
|
46
|
+
equal($div.width(), 0, "Test border specified with pixels");
|
47
|
+
|
48
|
+
$div.css({ "display": "", "border": "", "padding": "" });
|
49
|
+
|
50
|
+
jQuery("#nothiddendivchild").css({ "width": 20, "padding": "3px", "border": "2px solid #fff" });
|
51
|
+
equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
|
52
|
+
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "width": "" });
|
53
|
+
|
54
|
+
blah = jQuery("blah");
|
55
|
+
equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
|
56
|
+
equal( blah.width(), null, "Make sure 'null' is returned on an empty set");
|
57
|
+
|
58
|
+
equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
|
59
|
+
|
60
|
+
QUnit.expectJqData( $div[0], "olddisplay" );
|
61
|
+
}
|
62
|
+
|
63
|
+
test("width()", function() {
|
64
|
+
testWidth( pass );
|
65
|
+
});
|
66
|
+
|
67
|
+
test("width(Function)", function() {
|
68
|
+
testWidth( fn );
|
69
|
+
});
|
70
|
+
|
71
|
+
test("width(Function(args))", function() {
|
72
|
+
expect( 2 );
|
73
|
+
|
74
|
+
var $div = jQuery("#nothiddendiv");
|
75
|
+
$div.width( 30 ).width(function(i, width) {
|
76
|
+
equal( width, 30, "Make sure previous value is correct." );
|
77
|
+
return width + 1;
|
78
|
+
});
|
79
|
+
|
80
|
+
equal( $div.width(), 31, "Make sure value was modified correctly." );
|
81
|
+
});
|
82
|
+
|
83
|
+
function testHeight( val ) {
|
84
|
+
expect(9);
|
85
|
+
|
86
|
+
var $div, blah;
|
87
|
+
|
88
|
+
$div = jQuery("#nothiddendiv");
|
89
|
+
$div.height( val(30) );
|
90
|
+
equal($div.height(), 30, "Test set to 30 correctly");
|
91
|
+
$div.hide();
|
92
|
+
equal($div.height(), 30, "Test hidden div");
|
93
|
+
$div.show();
|
94
|
+
$div.height( val(-1) ); // handle negative numbers by setting to 0 #11604
|
95
|
+
equal($div.height(), 0, "Test negative height normalized to 0");
|
96
|
+
$div.css("padding", "20px");
|
97
|
+
equal($div.height(), 0, "Test padding specified with pixels");
|
98
|
+
$div.css("border", "2px solid #fff");
|
99
|
+
equal($div.height(), 0, "Test border specified with pixels");
|
100
|
+
|
101
|
+
$div.css({ "display": "", "border": "", "padding": "", "height": "1px" });
|
102
|
+
|
103
|
+
jQuery("#nothiddendivchild").css({ "height": 20, "padding": "3px", "border": "2px solid #fff" });
|
104
|
+
equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
|
105
|
+
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "height": "" });
|
106
|
+
|
107
|
+
blah = jQuery("blah");
|
108
|
+
equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
|
109
|
+
equal( blah.height(), null, "Make sure 'null' is returned on an empty set");
|
110
|
+
|
111
|
+
equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
|
112
|
+
|
113
|
+
QUnit.expectJqData( $div[0], "olddisplay" );
|
114
|
+
}
|
115
|
+
|
116
|
+
test("height()", function() {
|
117
|
+
testHeight( pass );
|
118
|
+
});
|
119
|
+
|
120
|
+
test("height(Function)", function() {
|
121
|
+
testHeight( fn );
|
122
|
+
});
|
123
|
+
|
124
|
+
test("height(Function(args))", function() {
|
125
|
+
expect( 2 );
|
126
|
+
|
127
|
+
var $div = jQuery("#nothiddendiv");
|
128
|
+
$div.height( 30 ).height(function(i, height) {
|
129
|
+
equal( height, 30, "Make sure previous value is correct." );
|
130
|
+
return height + 1;
|
131
|
+
});
|
132
|
+
|
133
|
+
equal( $div.height(), 31, "Make sure value was modified correctly." );
|
134
|
+
});
|
135
|
+
|
136
|
+
test("innerWidth()", function() {
|
137
|
+
expect(6);
|
138
|
+
|
139
|
+
var $div, div,
|
140
|
+
winWidth = jQuery( window ).width(),
|
141
|
+
docWidth = jQuery( document ).width();
|
142
|
+
|
143
|
+
equal(jQuery(window).innerWidth(), winWidth, "Test on window");
|
144
|
+
equal(jQuery(document).innerWidth(), docWidth, "Test on document");
|
145
|
+
|
146
|
+
$div = jQuery("#nothiddendiv");
|
147
|
+
// set styles
|
148
|
+
$div.css({
|
149
|
+
"margin": 10,
|
150
|
+
"border": "2px solid #fff",
|
151
|
+
"width": 30
|
152
|
+
});
|
153
|
+
|
154
|
+
equal($div.innerWidth(), 30, "Test with margin and border");
|
155
|
+
$div.css("padding", "20px");
|
156
|
+
equal($div.innerWidth(), 70, "Test with margin, border and padding");
|
157
|
+
$div.hide();
|
158
|
+
equal($div.innerWidth(), 70, "Test hidden div");
|
159
|
+
|
160
|
+
// reset styles
|
161
|
+
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
162
|
+
|
163
|
+
div = jQuery( "<div>" );
|
164
|
+
|
165
|
+
// Temporarily require 0 for backwards compat - should be auto
|
166
|
+
equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
167
|
+
|
168
|
+
div.remove();
|
169
|
+
QUnit.expectJqData( $div[0], "olddisplay" );
|
170
|
+
});
|
171
|
+
|
172
|
+
test("innerHeight()", function() {
|
173
|
+
expect(6);
|
174
|
+
|
175
|
+
var $div, div,
|
176
|
+
winHeight = jQuery( window ).height(),
|
177
|
+
docHeight = jQuery( document ).height();
|
178
|
+
|
179
|
+
equal(jQuery(window).innerHeight(), winHeight, "Test on window");
|
180
|
+
equal(jQuery(document).innerHeight(), docHeight, "Test on document");
|
181
|
+
|
182
|
+
$div = jQuery("#nothiddendiv");
|
183
|
+
// set styles
|
184
|
+
$div.css({
|
185
|
+
"margin": 10,
|
186
|
+
"border": "2px solid #fff",
|
187
|
+
"height": 30
|
188
|
+
});
|
189
|
+
|
190
|
+
equal($div.innerHeight(), 30, "Test with margin and border");
|
191
|
+
$div.css("padding", "20px");
|
192
|
+
equal($div.innerHeight(), 70, "Test with margin, border and padding");
|
193
|
+
$div.hide();
|
194
|
+
equal($div.innerHeight(), 70, "Test hidden div");
|
195
|
+
|
196
|
+
// reset styles
|
197
|
+
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
198
|
+
|
199
|
+
div = jQuery( "<div>" );
|
200
|
+
|
201
|
+
// Temporarily require 0 for backwards compat - should be auto
|
202
|
+
equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
203
|
+
|
204
|
+
div.remove();
|
205
|
+
QUnit.expectJqData( $div[0], "olddisplay" );
|
206
|
+
});
|
207
|
+
|
208
|
+
test("outerWidth()", function() {
|
209
|
+
expect(11);
|
210
|
+
|
211
|
+
var $div, div,
|
212
|
+
winWidth = jQuery( window ).width(),
|
213
|
+
docWidth = jQuery( document ).width();
|
214
|
+
|
215
|
+
equal( jQuery( window ).outerWidth(), winWidth, "Test on window without margin option" );
|
216
|
+
equal( jQuery( window ).outerWidth( true ), winWidth, "Test on window with margin option" );
|
217
|
+
equal( jQuery( document ).outerWidth(), docWidth, "Test on document without margin option" );
|
218
|
+
equal( jQuery( document ).outerWidth( true ), docWidth, "Test on document with margin option" );
|
219
|
+
|
220
|
+
$div = jQuery("#nothiddendiv");
|
221
|
+
$div.css("width", 30);
|
222
|
+
|
223
|
+
equal($div.outerWidth(), 30, "Test with only width set");
|
224
|
+
$div.css("padding", "20px");
|
225
|
+
equal($div.outerWidth(), 70, "Test with padding");
|
226
|
+
$div.css("border", "2px solid #fff");
|
227
|
+
equal($div.outerWidth(), 74, "Test with padding and border");
|
228
|
+
$div.css("margin", "10px");
|
229
|
+
equal($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
|
230
|
+
$div.css("position", "absolute");
|
231
|
+
equal($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
|
232
|
+
$div.hide();
|
233
|
+
equal($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
|
234
|
+
|
235
|
+
// reset styles
|
236
|
+
$div.css({ "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
237
|
+
|
238
|
+
div = jQuery( "<div>" );
|
239
|
+
|
240
|
+
// Temporarily require 0 for backwards compat - should be auto
|
241
|
+
equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
242
|
+
|
243
|
+
div.remove();
|
244
|
+
QUnit.expectJqData( $div[0], "olddisplay" );
|
245
|
+
});
|
246
|
+
|
247
|
+
test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
|
248
|
+
expect(16);
|
249
|
+
|
250
|
+
// setup html
|
251
|
+
var $divNormal = jQuery("<div>").css({ "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
252
|
+
$divChild = $divNormal.clone(),
|
253
|
+
$divUnconnected = $divNormal.clone(),
|
254
|
+
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
255
|
+
$divNormal.appendTo("body");
|
256
|
+
|
257
|
+
// tests that child div of a hidden div works the same as a normal div
|
258
|
+
equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
|
259
|
+
equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
|
260
|
+
equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
|
261
|
+
equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
|
262
|
+
|
263
|
+
equal( $divChild.height(), $divNormal.height(), "child of a hidden element height() is wrong see #9441" );
|
264
|
+
equal( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #9441" );
|
265
|
+
equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #9441" );
|
266
|
+
equal( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
|
267
|
+
|
268
|
+
// tests that child div of an unconnected div works the same as a normal div
|
269
|
+
equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
|
270
|
+
equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
|
271
|
+
equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
|
272
|
+
equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
|
273
|
+
|
274
|
+
equal( $divUnconnected.height(), $divNormal.height(), "unconnected element height() is wrong see #9441" );
|
275
|
+
equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #9441" );
|
276
|
+
equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #9441" );
|
277
|
+
equal( $divUnconnected.outerHeight(true), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #9300" );
|
278
|
+
|
279
|
+
// teardown html
|
280
|
+
$divHiddenParent.remove();
|
281
|
+
$divNormal.remove();
|
282
|
+
});
|
283
|
+
|
284
|
+
test("getting dimensions shouldn't modify runtimeStyle see #9233", function() {
|
285
|
+
expect( 1 );
|
286
|
+
|
287
|
+
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
288
|
+
div = $div.get( 0 ),
|
289
|
+
runtimeStyle = div.runtimeStyle;
|
290
|
+
|
291
|
+
if ( runtimeStyle ) {
|
292
|
+
div.runtimeStyle.marginLeft = "12em";
|
293
|
+
div.runtimeStyle.left = "11em";
|
294
|
+
}
|
295
|
+
|
296
|
+
$div.outerWidth( true );
|
297
|
+
|
298
|
+
if ( runtimeStyle ) {
|
299
|
+
equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
|
300
|
+
} else {
|
301
|
+
ok( true, "this browser doesn't support runtimeStyle, see #9233" );
|
302
|
+
}
|
303
|
+
|
304
|
+
$div.remove();
|
305
|
+
});
|
306
|
+
|
307
|
+
test( "table dimensions", 2, function() {
|
308
|
+
var table = jQuery("<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>").appendTo("#qunit-fixture"),
|
309
|
+
tdElem = table.find("td").first(),
|
310
|
+
colElem = table.find("col").first().width( 300 );
|
311
|
+
|
312
|
+
table.find("td").css({ "margin": 0, "padding": 0 });
|
313
|
+
|
314
|
+
equal( tdElem.width(), tdElem.width(), "width() doesn't alter dimension values of empty cells, see #11293" );
|
315
|
+
equal( colElem.width(), 300, "col elements have width(), see #12243" );
|
316
|
+
});
|
317
|
+
|
318
|
+
test("box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function() {
|
319
|
+
expect(16);
|
320
|
+
|
321
|
+
// setup html
|
322
|
+
var $divNormal = jQuery("<div>").css({ "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
323
|
+
$divChild = $divNormal.clone(),
|
324
|
+
$divUnconnected = $divNormal.clone(),
|
325
|
+
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
326
|
+
$divNormal.appendTo("body");
|
327
|
+
|
328
|
+
// tests that child div of a hidden div works the same as a normal div
|
329
|
+
equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
|
330
|
+
equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
|
331
|
+
equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
|
332
|
+
equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
|
333
|
+
|
334
|
+
equal( $divChild.height(), $divNormal.height(), "child of a hidden element height() is wrong see #10413" );
|
335
|
+
equal( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #10413" );
|
336
|
+
equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #10413" );
|
337
|
+
equal( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
|
338
|
+
|
339
|
+
// tests that child div of an unconnected div works the same as a normal div
|
340
|
+
equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
|
341
|
+
equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
|
342
|
+
equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
|
343
|
+
equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
|
344
|
+
|
345
|
+
equal( $divUnconnected.height(), $divNormal.height(), "unconnected element height() is wrong see #10413" );
|
346
|
+
equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #10413" );
|
347
|
+
equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #10413" );
|
348
|
+
equal( $divUnconnected.outerHeight(true), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #10413" );
|
349
|
+
|
350
|
+
// teardown html
|
351
|
+
$divHiddenParent.remove();
|
352
|
+
$divNormal.remove();
|
353
|
+
});
|
354
|
+
|
355
|
+
test("outerHeight()", function() {
|
356
|
+
expect(11);
|
357
|
+
|
358
|
+
var $div, div,
|
359
|
+
winHeight = jQuery( window ).height(),
|
360
|
+
docHeight = jQuery( document ).height();
|
361
|
+
|
362
|
+
|
363
|
+
equal( jQuery( window ).outerHeight(), winHeight, "Test on window without margin option" );
|
364
|
+
equal( jQuery( window ).outerHeight( true ), winHeight, "Test on window with margin option" );
|
365
|
+
equal( jQuery( document ).outerHeight(), docHeight, "Test on document without margin option" );
|
366
|
+
equal( jQuery( document ).outerHeight( true ), docHeight, "Test on document with margin option" );
|
367
|
+
|
368
|
+
$div = jQuery("#nothiddendiv");
|
369
|
+
$div.css("height", 30);
|
370
|
+
|
371
|
+
equal($div.outerHeight(), 30, "Test with only width set");
|
372
|
+
$div.css("padding", "20px");
|
373
|
+
equal($div.outerHeight(), 70, "Test with padding");
|
374
|
+
$div.css("border", "2px solid #fff");
|
375
|
+
equal($div.outerHeight(), 74, "Test with padding and border");
|
376
|
+
$div.css("margin", "10px");
|
377
|
+
equal($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
|
378
|
+
equal($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
|
379
|
+
$div.hide();
|
380
|
+
equal($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
|
381
|
+
|
382
|
+
// reset styles
|
383
|
+
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
384
|
+
|
385
|
+
div = jQuery( "<div>" );
|
386
|
+
|
387
|
+
// Temporarily require 0 for backwards compat - should be auto
|
388
|
+
equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
389
|
+
|
390
|
+
div.remove();
|
391
|
+
QUnit.expectJqData( $div[0], "olddisplay" );
|
392
|
+
});
|
393
|
+
|
394
|
+
test("passing undefined is a setter #5571", function() {
|
395
|
+
expect(4);
|
396
|
+
equal(jQuery("#nothiddendiv").height(30).height(undefined).height(), 30, ".height(undefined) is chainable (#5571)");
|
397
|
+
equal(jQuery("#nothiddendiv").height(30).innerHeight(undefined).height(), 30, ".innerHeight(undefined) is chainable (#5571)");
|
398
|
+
equal(jQuery("#nothiddendiv").height(30).outerHeight(undefined).height(), 30, ".outerHeight(undefined) is chainable (#5571)");
|
399
|
+
equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
|
400
|
+
});
|
401
|
+
|
402
|
+
test( "getters on non elements should return null", function() {
|
403
|
+
expect( 8 );
|
404
|
+
|
405
|
+
var nonElem = jQuery("notAnElement");
|
406
|
+
|
407
|
+
strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
|
408
|
+
strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
|
409
|
+
strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" );
|
410
|
+
strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" );
|
411
|
+
|
412
|
+
strictEqual( nonElem.height(), null, ".height() is not null (#12283)" );
|
413
|
+
strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" );
|
414
|
+
strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" );
|
415
|
+
strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" );
|
416
|
+
});
|
417
|
+
|
418
|
+
test("setters with and without box-sizing:border-box", function(){
|
419
|
+
expect(20);
|
420
|
+
|
421
|
+
var el_bb = jQuery("<div style='width:114px;height:114px;margin:5px;padding:3px;border:4px solid white;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>").appendTo("#qunit-fixture"),
|
422
|
+
el = jQuery("<div style='width:100px;height:100px;margin:5px;padding:3px;border:4px solid white;'>test</div>").appendTo("#qunit-fixture"),
|
423
|
+
expected = 100;
|
424
|
+
|
425
|
+
equal( el_bb.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" );
|
426
|
+
equal( el_bb.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" );
|
427
|
+
equal( el_bb.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" );
|
428
|
+
equal( el_bb.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" );
|
429
|
+
equal( el_bb.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" );
|
430
|
+
|
431
|
+
equal( el_bb.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" );
|
432
|
+
equal( el_bb.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" );
|
433
|
+
equal( el_bb.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" );
|
434
|
+
equal( el_bb.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" );
|
435
|
+
equal( el_bb.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
|
436
|
+
|
437
|
+
equal( el.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" );
|
438
|
+
equal( el.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" );
|
439
|
+
equal( el.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" );
|
440
|
+
equal( el.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" );
|
441
|
+
equal( el.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" );
|
442
|
+
|
443
|
+
equal( el.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" );
|
444
|
+
equal( el.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" );
|
445
|
+
equal( el.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" );
|
446
|
+
equal( el.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" );
|
447
|
+
equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
|
448
|
+
});
|
449
|
+
|
450
|
+
testIframe( "dimensions/documentSmall", "window vs. small document", function( jQuery, window, document ) {
|
451
|
+
// this test is practically tautological, but there is a bug in IE8
|
452
|
+
// with no simple workaround, so this test exposes the bug and works around it
|
453
|
+
if ( document.body.offsetWidth >= document.documentElement.offsetWidth ) {
|
454
|
+
expect( 2 );
|
455
|
+
|
456
|
+
equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" );
|
457
|
+
equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" );
|
458
|
+
} else {
|
459
|
+
// all tests should have at least one assertion
|
460
|
+
expect( 1 );
|
461
|
+
ok( true, "skipping test (conditions not satisfied)" );
|
462
|
+
}
|
463
|
+
});
|
464
|
+
|
465
|
+
testIframe( "dimensions/documentLarge", "window vs. large document", function( jQuery, window, document ) {
|
466
|
+
expect(2);
|
467
|
+
|
468
|
+
ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" );
|
469
|
+
ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
|
470
|
+
});
|
471
|
+
|
472
|
+
})();
|