Skip to content

Instantly share code, notes, and snippets.

View mmonteleone's full-sized avatar

Michael Monteleone mmonteleone

View GitHub Profile
@mmonteleone
mmonteleone / gist:1209097
Created September 11, 2011 02:40
Cloned Radio Input Checked State Test
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Radio Clone Test</title>
<script type="text/javascript">
/* Example of checked state of a radio input not being retained in a twice-cloned node.
Fails in Safari 4.0.5.
Passes in 5.1 */
window.onload = function() {
var div = document.createElement("div");
/**
* Mocks a function with a custom mocked handler for the duration
* of the execution of a context function
* @param {Object} parent the parent scope of the function being mocked
* @param {String} functionName the name of the function being mocked
* @param {Function} mockedFunction replacement function to use as the mocked function
* @param {Function} context code to execute while function is mocked
*/
var mock = function(parent, functionName, mockedFunction, context) {
var nativeFunction = parent[functionName];