Skip to content

Instantly share code, notes, and snippets.

Bryan Forbes bryanforbes

Block or report user

Report or block bryanforbes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:610288
addtest('bug-root-children-arent-styled', function(g, d, e){
var result = null, root;
if(d && d.documentElement && e){
root = d.documentElement; = 'width:40px;height:40px;';
root.insertBefore(e, root.firstChild);
result = e.clientWidth == 0;
View helper.js
var NON_HOST_TYPES = { "boolean": 1, "number": 1, "string": 1, "undefined": 1 },
_listen, _stopListening, normalizeEventName;
// Imported from
// Host objects can return type values that are different from their actual
// data type. The objects we are concerned with usually return non-primitive
// types of object, function, or unknown.
function isHostType(object, property){
var type = typeof object[property];
View no_leak_1.html
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="refresh" content="2;url=">
<title>Leak Fix with Lookup Wrapper</title>
<script src="helper.js"></script>
var _cache = {};
var createWrapper = (function(){
bryanforbes / gist:663298
Created Nov 4, 2010
This is an attempt to explain what is happening behind the scenes with event handlers in ES3 and why IE leaks in one case and not another.
View gist:663298
// Global Object
// (§10.2.1)
// GO.scope_chain = [GO]
// GO._cache = _cache
var _cache = {};
// Declaration (§13.2):
// CWanonfunc.[[Scope]] = GO.scope_chain.slice(0) (§13.2 step 7)
bryanforbes / dispatcher.js
Created Dec 15, 2010
A simple event disptacher to prevent leaks
View dispatcher.js
var eventData = {};
function createDispatcher(id){
function dispatcher(){
if(id in _evtData){
_evtData[id].handler.apply(this, arguments);
return dispatcher;
View guid.js
var guid = (function(){
function hasUniqueNumber(){
var docEl = document.documentElement, elem = document.createElement("div");
return (typeof elem.uniqueNumber == "number" && typeof docEl.uniqueNumber == "number" &&
elem.uniqueNumber != docEl.uniqueNumber);
var guid, last = 1;
View keyboard.html
<html lang="en">
<meta charset="utf-8">
<input id="txt" />
var txt = document.getElementById("txt"),
View keyboard-events.html
<html lang="en">
<meta charset="utf-8">
<input id="txt" type="text">
var attach;
View bool.js
var Boolean = (function(){
var undefinedThis = (function(){
return this; // this depends on strict mode
function Boolean(arg){
if(this == undefinedThis){
return !!arg;
return {};
bryanforbes / a.js
Created May 13, 2011
Recursive module requires
View a.js
define([], function(){
return {};
You can’t perform that action at this time.