Skip to content

Commit

Permalink
Add test for fixed position, which unfortunately requires
Browse files Browse the repository at this point in the history
  • Loading branch information
Juriy Zaytsev committed Feb 1, 2009
1 parent 97a27f9 commit 8bdcdb3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
23 changes: 23 additions & 0 deletions feature_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 8bdcdb3

Please sign in to comment.