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;
e.style.cssText = 'width:40px;height:40px;';
try{
root.insertBefore(e, root.firstChild);
result = e.clientWidth == 0;
View helper.js
(function(global){
var NON_HOST_TYPES = { "boolean": 1, "number": 1, "string": 1, "undefined": 1 },
_listen, _stopListening, normalizeEventName;
// Imported from http://github.com/phiggins42/has.js.
// 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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="2;url=">
<title>Leak Fix with Lookup Wrapper</title>
<script src="helper.js"></script>
<script>
var _cache = {};
var createWrapper = (function(){
@bryanforbes
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
bryanforbes / dispatcher.js
Created Dec 15, 2010
A simple event disptacher to prevent leaks
View dispatcher.js
var eventData = {};
(function(global){
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;
if(hasUniqueNumber()){
View keyboard.html
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<input id="txt" />
<script>
var txt = document.getElementById("txt"),
View keyboard-events.html
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<input id="txt" type="text">
<script>
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;
}else{
return {};
}
@bryanforbes
bryanforbes / a.js
Created May 13, 2011
Recursive module requires
View a.js
define([], function(){
require(['tests/recurse/b']);
return {};
});
You can’t perform that action at this time.