@@ -167,7 +167,7 @@ test("Persist correct display value", function() {
167
167
} ) ;
168
168
} ) ;
169
169
170
- test ( "show() resolves correct default display #8099" , function ( ) {
170
+ test ( "show() resolves correct default display ( #8099) " , function ( ) {
171
171
expect ( 7 ) ;
172
172
var tt8099 = jQuery ( "<tt/>" ) . appendTo ( "body" ) ,
173
173
dfn8099 = jQuery ( "<dfn/>" , { html : "foo" } ) . appendTo ( "body" ) ;
@@ -185,7 +185,60 @@ test("show() resolves correct default display #8099", function() {
185
185
186
186
tt8099 . remove ( ) ;
187
187
dfn8099 . remove ( ) ;
188
+ } ) ;
189
+
190
+ test ( "show() resolves correct default display, detached nodes (#10006)" , function ( ) {
191
+ // Tests originally contributed by Orkel in
192
+ // https://github.com/jquery/jquery/pull/458
193
+ expect ( 11 ) ;
194
+
195
+ var div , span ;
196
+
197
+ div = jQuery ( "<div class='hidden'>" ) ;
198
+ div . show ( ) . appendTo ( "#qunit-fixture" ) ;
199
+ equal ( div . css ( "display" ) , "block" , "Make sure a detached, pre-hidden( through stylesheets ) div is visible." ) ;
200
+
201
+ div = jQuery ( "<div style='display: none'>" ) ;
202
+ div . show ( ) . appendTo ( "#qunit-fixture" ) ;
203
+ equal ( div . css ( "display" ) , "block" , "Make sure a detached, pre-hidden( through inline style ) div is visible." ) ;
204
+
205
+ span = jQuery ( "<span class='hidden'/>" ) ;
206
+ span . show ( ) . appendTo ( "#qunit-fixture" ) ;
207
+ equal ( span . css ( "display" ) , "inline" , "Make sure a detached, pre-hidden( through stylesheets ) span has default display." ) ;
208
+
209
+ span = jQuery ( "<span style='display: inline'/>" ) ;
210
+ span . show ( ) . appendTo ( "#qunit-fixture" ) ;
211
+ equal ( span . css ( "display" ) , "inline" , "Make sure a detached, pre-hidden( through inline style ) span has default display." ) ;
212
+
213
+ div = jQuery ( "<div><div class='hidden'></div></div>" ) . children ( "div" ) ;
214
+ div . show ( ) . appendTo ( "#qunit-fixture" ) ;
215
+ equal ( div . css ( "display" ) , "block" , "Make sure a detached, pre-hidden( through stylesheets ) div inside another visible div is visible." ) ;
216
+
217
+ div = jQuery ( "<div><div style='display: none'></div></div>" ) . children ( "div" ) ;
218
+ div . show ( ) . appendTo ( "#qunit-fixture" ) ;
219
+ equal ( div . css ( "display" ) , "block" , "Make sure a detached, pre-hidden( through inline style ) div inside another visible div is visible." ) ;
220
+
221
+ div = jQuery ( "div.hidden" ) ;
222
+ div . detach ( ) . show ( ) ;
223
+ equal ( div . css ( "display" ) , "block" , "Make sure a detached( through detach() ), pre-hidden div is visible." ) ;
224
+ div . remove ( ) ;
225
+
226
+ span = jQuery ( "<span>" ) ;
227
+ span . appendTo ( "#qunit-fixture" ) . detach ( ) . show ( ) . appendTo ( "#qunit-fixture" ) ;
228
+ equal ( span . css ( "display" ) , "inline" , "Make sure a detached( through detach() ), pre-hidden span has default display." ) ;
229
+ span . remove ( ) ;
230
+
231
+ div = jQuery ( "<div>" ) ;
232
+ div . show ( ) . appendTo ( "#qunit-fixture" ) ;
233
+ ok ( ! ! div . get ( 0 ) . style . display , "Make sure not hidden div has a inline style." ) ;
234
+
235
+ div = jQuery ( document . createElement ( "div" ) ) ;
236
+ div . show ( ) . appendTo ( "#qunit-fixture" ) ;
237
+ equal ( div . css ( "display" ) , "block" , "Make sure a pre-created element has default display." ) ;
188
238
239
+ div = jQuery ( "<div style='display: inline'/>" ) ;
240
+ div . show ( ) . appendTo ( "#qunit-fixture" ) ;
241
+ equal ( div . css ( "display" ) , "inline" , "Make sure that element has same display when it was created." ) ;
189
242
} ) ;
190
243
191
244
0 commit comments