Permalink
Browse files

Add test for fixed position, which unfortunately requires

  • Loading branch information...
1 parent 97a27f9 commit 8bdcdb378c540c030be2c1d039a9a88c4bcad786 Juriy Zaytsev committed Feb 1, 2009
Showing with 35 additions and 2 deletions.
  1. +23 −0 feature_tests.js
  2. +12 −2 index.html
View
@@ -183,6 +183,29 @@ SOFTWARE.
return null;
})();
+ features.IS_POSITION_FIXED_SUPPORTED = (features.__IS_POSITION_FIXED_SUPPORTED = function(){
+ var isSupported = null;
+ if (document.createElement) {
+ var el = document.createElement('div');
+ if (el && el.style) {
+ el.style.width = '1px';
+ el.style.height = '1px';
+ el.style.position = 'fixed';
+ el.style.top = '10px';
+ var root = document.body;
+ if (root &&
+ root.appendChild &&
+ root.removeChild) {
+ root.appendChild(el);
+ isSupported = (el.offsetTop === 10);
+ root.removeChild(el);
+ }
+ el = null;
+ }
+ }
+ return isSupported;
+ })();
+
// BUGGIES
// Safari returns "function" as typeof HTMLCollection
View
@@ -6,7 +6,6 @@
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Javascript feature tests</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen">
- <script src="feature_tests.js" type="text/javascript"></script>
</head>
<body>
@@ -34,7 +33,7 @@ <h1>Common feature tests:</h1>
</p>
</div>
<p>
- <span id="last-updated" class="dtstart">Last updated: Dec 26 2008</span>
+ <span id="last-updated" class="dtstart">Last updated: Jan 26 2008</span>
</p>
<h2>Features:</h2>
@@ -165,6 +164,16 @@ <h2>Features:</h2>
<td><a href="#" title="show test code" class="show-test-code">show</a></td>
</tr>
<tr style="display:none"><td colspan="5" class="test-code"><pre></pre></td></tr>
+ <tr>
+ <td>IS_POSITION_FIXED_SUPPORTED</td>
+ <td></td>
+ <td>-</td>
+ <td>
+ Check if `position:fixed` is supported. <strong>Requires</strong> presence of document.body
+ </td>
+ <td><a href="#" title="show test code" class="show-test-code">show</a></td>
+ </tr>
+ <tr style="display:none"><td colspan="5" class="test-code"><pre></pre></td></tr>
</tbody>
</table>
@@ -318,6 +327,7 @@ <h2>Bugs:</h2>
</tbody>
</table>
+ <script src="feature_tests.js" type="text/javascript"></script>
<script src="master.js" type="text/javascript"></script>
<script type="text/javascript">

0 comments on commit 8bdcdb3

Please sign in to comment.