Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add test for fixed position, which unfortunately requires

  • Loading branch information...
commit 8bdcdb378c540c030be2c1d039a9a88c4bcad786 1 parent 97a27f9
authored February 01, 2009
23  feature_tests.js
@@ -183,6 +183,29 @@ SOFTWARE.
183 183
     return null;
184 184
   })();
185 185
   
  186
+  features.IS_POSITION_FIXED_SUPPORTED = (features.__IS_POSITION_FIXED_SUPPORTED = function(){
  187
+    var isSupported = null;
  188
+    if (document.createElement) {
  189
+      var el = document.createElement('div');
  190
+      if (el && el.style) {
  191
+        el.style.width = '1px';
  192
+        el.style.height = '1px';
  193
+        el.style.position = 'fixed';
  194
+        el.style.top = '10px';
  195
+        var root = document.body;
  196
+        if (root && 
  197
+            root.appendChild && 
  198
+            root.removeChild) {
  199
+          root.appendChild(el);
  200
+          isSupported = (el.offsetTop === 10);
  201
+          root.removeChild(el);
  202
+        }
  203
+        el = null;
  204
+      }
  205
+    }
  206
+    return isSupported;
  207
+  })();
  208
+  
186 209
   // BUGGIES
187 210
   
188 211
   // Safari returns "function" as typeof HTMLCollection
14  index.html
@@ -6,7 +6,6 @@
6 6
     <meta http-equiv="Content-Style-Type" content="text/css">
7 7
     <title>Javascript feature tests</title>
8 8
     <link rel="stylesheet" href="master.css" type="text/css" media="screen">
9  
-    <script src="feature_tests.js" type="text/javascript"></script>
10 9
   </head>
11 10
   <body>
12 11
     
@@ -34,7 +33,7 @@
34 33
       </p>
35 34
     </div>
36 35
     <p>
37  
-      <span id="last-updated" class="dtstart">Last updated: Dec 26 2008</span>
  36
+      <span id="last-updated" class="dtstart">Last updated: Jan 26 2008</span>
38 37
     </p>
39 38
     
40 39
     <h2>Features:</h2>
@@ -165,6 +164,16 @@
165 164
           <td><a href="#" title="show test code" class="show-test-code">show</a></td>
166 165
         </tr>
167 166
         <tr style="display:none"><td colspan="5" class="test-code"><pre></pre></td></tr>
  167
+        <tr>
  168
+          <td>IS_POSITION_FIXED_SUPPORTED</td>
  169
+          <td></td>
  170
+          <td>-</td>
  171
+          <td>
  172
+            Check if `position:fixed` is supported. <strong>Requires</strong> presence of document.body
  173
+          </td>
  174
+          <td><a href="#" title="show test code" class="show-test-code">show</a></td>
  175
+        </tr>
  176
+        <tr style="display:none"><td colspan="5" class="test-code"><pre></pre></td></tr>
168 177
       </tbody>
169 178
     </table>
170 179
     
@@ -318,6 +327,7 @@
318 327
       </tbody>
319 328
     </table>
320 329
     
  330
+    <script src="feature_tests.js" type="text/javascript"></script>
321 331
     <script src="master.js" type="text/javascript"></script>
322 332
     
323 333
     <script type="text/javascript">

0 notes on commit 8bdcdb3

Please sign in to comment.
Something went wrong with that request. Please try again.