Side navigation
Ticket #4965: testcase.html
File testcase.html, 1.5 KB (added by brendo_, July 24, 2009 09:59AM UTC)
Test Case (jQuery not provided)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Safari hasClass Bug</title>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.field-date').each(function() {
self = $(this);
if(self.hasClass('field-date')) {
self.html("jquery:true");
} else {
self.html("jquery:false");
}
});
var fields = document.getElementsByClassName('field-date');
for(var i = 0; i < fields.length; i++) {
var el = document.getElementById('raw');
if(hasClass(fields[i],'field-date')) {
el.innerHTML += "raw:true";
} else {
el.innerHTML += "raw:false";
}
}
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
});
</script>
<style type='text/css'>
#red {
background: red;
}
#blue {
background: blue;
color: #FFF;
}
</style>
</head>
<body>
<div id='container'>
<div id='raw'>
</div>
<div id='red' class='field field-text field-size-single field-date read-only'>
Red
</div>
<div id='blue' class='field field-text field-size-single field-date read-only'>
Blue
</div>
</div>
</body>
</html>
Download in other formats:
Original Format
File testcase.html, 1.5 KB (added by brendo_, July 24, 2009 09:59AM UTC)
Test Case (jQuery not provided)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Safari hasClass Bug</title>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.field-date').each(function() {
self = $(this);
if(self.hasClass('field-date')) {
self.html("jquery:true");
} else {
self.html("jquery:false");
}
});
var fields = document.getElementsByClassName('field-date');
for(var i = 0; i < fields.length; i++) {
var el = document.getElementById('raw');
if(hasClass(fields[i],'field-date')) {
el.innerHTML += "raw:true";
} else {
el.innerHTML += "raw:false";
}
}
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
});
</script>
<style type='text/css'>
#red {
background: red;
}
#blue {
background: blue;
color: #FFF;
}
</style>
</head>
<body>
<div id='container'>
<div id='raw'>
</div>
<div id='red' class='field field-text field-size-single field-date read-only'>
Red
</div>
<div id='blue' class='field field-text field-size-single field-date read-only'>
Blue
</div>
</div>
</body>
</html>