This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var slice = Array.prototype.slice, | |
arrayLike = {0: 'a', 1: 'b', 2: 'c', 3: 'd', length:4}, | |
a = slice.call(arrayLike), // undefined | |
b = slice.call(arrayLike, undefined); // the array as expected | |
print(a); // undefined | |
print(b); // "a,b,c,d" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BESEN strange behavior on named accessor property | |
// Tested on r77 | |
var obj = Object.defineProperty({}, 'foo', { set: undefined }), | |
desc = Object.getOwnPropertyDescriptor(obj, 'foo'); | |
// Definning a setter just to make the property a named accessor property. | |
// (`undefined` is a valid value for the [[Set]] and [[Get]] property attributes) | |
// the getter is correctly `undefined`, the FromPropertyDescriptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseDate(str, format) { | |
format = format || 'yyyy-mm-dd'; // default format | |
// build a regular expression to match the format | |
var i = 0, fmt = {}, | |
re = new RegExp('^'+format.replace(/(yyyy|dd|mm)/g, function (match) { | |
fmt[match] = ++i; // store format position | |
return '(\\d{'+match.length+'})'; // make a capturing group | |
})+'$'), parts = str.match(re); // match the date parts | |
if (!parts) return null; // input didn't match the format pattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var frameworks = { | |
'MooTools Core': 'MooTools.version', | |
'MooTools More': 'MooTools.More.version', | |
'Base2': 'base2.version', | |
'Dojo': 'dojo.version', | |
'Ext JS': 'Ext.version', | |
'jQuery': 'jQuery.fn.jquery', | |
'jQuery UI': 'jQuery.ui.version', | |
'MochKit': 'MochiKit.MochiKit.VERSION', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getStyle(el, styleProp) { | |
var value, defaultView = el.ownerDocument.defaultView; | |
// W3C standard way: | |
if (defaultView && defaultView.getComputedStyle) { | |
// sanitize property name to css notation (hypen separated words eg. font-Size) | |
styleProp = styleProp.replace(/([A-Z])/g, "-$1").toLowerCase(); | |
return defaultView.getComputedStyle(el, null).getPropertyValue(styleProp); | |
} else if (el.currentStyle) { // IE | |
// sanitize property name to camelCase | |
styleProp = styleProp.replace(/\-(\w)/g, function(str, letter) { |
NewerOlder