Skip to content

Instantly share code, notes, and snippets.

View fabiomcosta's full-sized avatar
:octocat:
void 0

Fabio M. Costa fabiomcosta

:octocat:
void 0
View GitHub Profile
var implement = function(key, value, retain){
if (Class.Mutators.hasOwnProperty(key)){
var mutator = Class.Mutators[key];
value = mutator.call(this, value);
if (value == null) return this;
}
if (typeOf(value) == 'function'){
if (value.$hidden) return this;
describe('Element.get/set/erase property exaustive', (function(){
var tagsAttrs = {
label: ['for'],
input: ['data-something', 'id', 'name', 'value', 'maxLength', 'readOnly', 'defaultValue', 'accessKey', 'checked', 'disabled', 'multiple', 'selected', 'noresize', 'onkeypress', 'onkeydown', 'onkeyup'],
button: ['type'], // theres a bug on safari while using type as an expando (el.type) with button elements
a: ['href', 'title', 'text', 'class', 'html', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout'],
img: ['src', 'ismap', 'useMap', 'tabIndex'],
table: ['cellPadding', 'cellSpacing'],
td: ['colSpan', 'rowSpan'],
iframe: ['frameBorder'],
/*
old delay function
delay: function(delay, bind, args){
return this.create({bind: bind, arguments: args, delay: delay})();
}
*/
/*
old delay function
delay: function(delay, bind, args){
return this.create({bind: bind, arguments: args, delay: delay})();
}
*/
// IE
var arrayFrom = Array.from;
try {
arrayFrom(document.html.childNodes);
} catch(e){
Array.from = function(item){
if (Type.isEnumerable(item)){
var i = item.length, array = new Array(i);
while (i--) array[i] = item[i];
return array;
@fabiomcosta
fabiomcosta / runner.js
Created December 22, 2009 23:21
A Console Jasmine Runner
// a console object that outputs at the terminal
load('shell_console.js');
// makes jasmine-0.10.0 stop breaking
var window = this;
window.setTimeout = function(){};
window.setInterval = function(){};
window.clearTimeout = function(){};
window.clearInterval = function(){};
XMLHttpRequest = function(){};
/*
Copyright (c) 2009 Rob Bast
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software
(function(){
var styleString = Element.getComputedStyle;
function styleNumber(element, style){
return styleString(element, style).toInt() || 0;
};
function isBody(element){
return (/^(?:body|html)$/i).test(element.tagName);
};
Element.implement({
getPosition: function(relative){
var old = Array.from;
try {
old(document.html.childNodes);
} catch(e){
Array.from = function(item, slice){
if (typeOf(item) == 'collection'){
var l = item.length, array = new Array(l - slice), i = slice - 1;
while (++i < l) array[i] = item[i];
return array;
}
Array.from = function(item, slice){
if(!item) return [];
if(!Type.isEnumerable(item)) return [item];
slice = slice || 0;
try{
return Array.prototype.slice.call(item, slice);
}
catch(e){
var l = item.length, array = new Array(l), i = slice;
for(; i < l; i++) array[i] = item[i];