Skip to content

Commit 33d2a9b

Browse files
committed
fix polyfill detection for @hidden
1 parent 24efa46 commit 33d2a9b

File tree

11 files changed

+67
-100
lines changed

11 files changed

+67
-100
lines changed

Readme.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,7 @@ Elements are hidden by toggling the HTML5 `hidden` attribute. Modern browsers su
6666
}
6767
```
6868

69-
Hopefully you're beyond needing IE6 support, but just in case:
70-
71-
```css
72-
* {
73-
_display: expression(this.hidden?'none':'inherit');
74-
}
75-
```
76-
77-
However, the script will check whether 'hidden' elements are visible. If they are, it will use the jQuery `.toggle()` method to control relevance. This results in the style `display` being change to `none` when elements are not relevant.
69+
However, the script will check whether 'hidden' elements remain visible. If they are, it will use the jQuery `.hide()` and `.slideDown()` methods to control relevance. This results in the style `display` being changed to `none` when elements are not relevant, and provides a fallback animation.
7870

7971
You can override `hidden` in modern browsers to implement CSS transitions. For example:
8072

dist/relevance.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! relevance - v2.0.0 - 2015-02-26
1+
/*! relevance - v2.0.0 - 2015-02-27
22
* https://github.com/bboyle/relevance
33
* Copyright (c) 2015 Ben Boyle; Licensed MIT */
44
if ( jQuery !== 'undefined' ) {
@@ -9,10 +9,10 @@ if ( jQuery !== 'undefined' ) {
99
irrelevantEvent = 'irrelevant',
1010
elementsToDisable = 'button, input, select, textarea',
1111
polyfillHidden = (function() {
12-
var hidden = $( '<div hidden/>' );
12+
var hidden = $( '<div hidden></div>' );
1313
var isHidden = hidden.appendTo( 'body' ).is( ':visible' );
1414
hidden.remove();
15-
return isHidden;
15+
return ! isHidden;
1616
}()),
1717

1818
formElementsByName = function( form, name ) {

dist/relevance.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/relevance.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ if ( jQuery !== 'undefined' ) {
77
irrelevantEvent = 'irrelevant',
88
elementsToDisable = 'button, input, select, textarea',
99
polyfillHidden = (function() {
10-
var hidden = $( '<div hidden/>' );
10+
var hidden = $( '<div hidden></div>' );
1111
var isHidden = hidden.appendTo( 'body' ).is( ':visible' );
1212
hidden.remove();
13-
return isHidden;
13+
return ! isHidden;
1414
}()),
1515

1616
formElementsByName = function( form, name ) {

test/events.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
color: #111;
2727
}
2828

29-
[hidden] {
30-
display: none;
31-
}
32-
3329
#qunit-fixture {
3430
position: static;
3531
}

test/instructions.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636
font-weight: bold;
3737
}
3838

39-
[hidden] {
40-
display: none;
41-
}
42-
* {
43-
_display: expression(this.hidden?'none':'inherit');
44-
}
45-
4639
#qunit-fixture {
4740
position: static;
4841
}

test/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
// start qunit
7575
start();
7676

77-
strictEqual( $( '#foo' ).is( '[hidden]' ), true, '#foo is hidden' );
77+
strictEqual( $( '#foo' ).is( ':hidden' ), true, '#foo is hidden' );
7878
strictEqual( $( '#foo' ).attr( 'aria-hidden' ), 'true', '#foo is aria-hidden when irrelevant' );
7979
ok( $( '#foo' ).attr( 'hidden' ), '#foo is @hidden when irrelevant' );
8080
strictEqual( $( '#foo' )[ 0 ].disabled, true, '#foo is @disabled when irrelevant' );

test/relevantWhen.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@
5151
background: black;
5252
}
5353

54-
[hidden] {
55-
display: none;
56-
}
57-
* {
58-
_display: expression(this.hidden?'none':'inherit');
59-
}
60-
6154
#qunit-fixture {
6255
position: static;
6356
}

0 commit comments

Comments
 (0)