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
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'],
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;
Type.isEnumerable = function(item){
return (typeof item != 'object' && typeof item != 'string' && typeof item.length == 'number');
};
if (!Browser.Element){
Element.parent = Object;
Element.ProtoType = {'$family': function(){ return 'element'; }.hide()};
Element.mirror(function(name, method){
Element.ProtoType[name] = method;
});
}
/*
---
script: Elements.From.js
description: Returns a collection of elements from a string of html.
license: MIT-style license
requires: [Element]
var getParent = function(expression){
var parsed = Slick.parse(expression);
parsed = parsed && parsed.expressions;
for (var i = parsed.length; i--;){
parsed[i][0] = '!';
}
return Slick.find(this, parsed);
};
(function(context){
var Configuration = context.Configuration = {};
Configuration.name = 'MooTools Slick';
Configuration.presets = {
'slick-1.0': {
sets: ['1.0'],
helpers: ['1.0'],
@fabiomcosta
fabiomcosta / msMatchesSelector_bug.js
Created February 20, 2011 20:02
msMatchesSelector errors on unattached nodes
// live demo: http://jsbin.com/oxuri5/9
var div = document.createElement('div');
div.setAttribute('attr', 'test');
console.log(div.msMatchesSelector('[attr="test"]'), ' should be true');
console.log(div.msMatchesSelector('[attr^="test"]'), ' should be true');
console.log(div.msMatchesSelector('[attr$="test"]'), ' should be true');
document.body.appendChild(div);
console.log(div.msMatchesSelector('[attr="test"]'), ' should be true');
console.log(div.msMatchesSelector('[attr^="test"]'), ' should be true');
var crypto = require("crypto");
var repeat = function(str, times){
var _str = str;
while(--times){
str += _str;
}
return str;
};
/*
---
Port from the YUI3 event-simulate functionality to vanilla javascript.
...
*/
(function(global, document){
var mix = function(obj1, obj2){
for (var key in obj2){
obj1[key] = obj2[key];