Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith committed Jul 28, 2011
2 parents 9370dc2 + bf6ad76 commit 7c7d811
Show file tree
Hide file tree
Showing 62 changed files with 2,178 additions and 307 deletions.
18 changes: 5 additions & 13 deletions build/dump/dump-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,16 @@ YUI.add('dump', function(Y) {
COMMA = ', ',
ARROW = ' => ',

/**
* The following methods are added to the YUI instance
* @class YUI~dump
*/

/**
* Returns a simple string representation of the object or array.
* Other types of objects will be returned unprocessed. Arrays
* are expected to be indexed. Use object notation for
* associative arrays.
*
* This method is in the 'dump' module, which is not bundled with
* the core YUI object
* are expected to be indexed.
*
* @method dump
* @param {object} o The object to dump.
* @param {int} d How deep to recurse child objects, default 3.
* @return {string} the dump result.
* @param {Object} o The object to dump.
* @param {Number} d How deep to recurse child objects, default 3.
* @return {String} the dump result.
* @for YUI
*/
dump = function(o, d) {
var i, len, s = [], type = L.type(o);
Expand Down
18 changes: 5 additions & 13 deletions build/dump/dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,16 @@ YUI.add('dump', function(Y) {
COMMA = ', ',
ARROW = ' => ',

/**
* The following methods are added to the YUI instance
* @class YUI~dump
*/

/**
* Returns a simple string representation of the object or array.
* Other types of objects will be returned unprocessed. Arrays
* are expected to be indexed. Use object notation for
* associative arrays.
*
* This method is in the 'dump' module, which is not bundled with
* the core YUI object
* are expected to be indexed.
*
* @method dump
* @param {object} o The object to dump.
* @param {int} d How deep to recurse child objects, default 3.
* @return {string} the dump result.
* @param {Object} o The object to dump.
* @param {Number} d How deep to recurse child objects, default 3.
* @return {String} the dump result.
* @for YUI
*/
dump = function(o, d) {
var i, len, s = [], type = L.type(o);
Expand Down
206 changes: 99 additions & 107 deletions build/oop/oop-debug.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
YUI.add('oop', function(Y) {

/**
Supplies object inheritance and manipulation utilities.
This adds additional functionaity to what is provided in `yui-base`, and the
methods are applied directly to the YUI instance. This module is required for
most YUI components.
Adds object inheritance and manipulation utilities to the YUI instance. This
module is required by most YUI components.
@module oop
**/

/**
These methods are added to the YUI instance by the `oop` module.
@class YUI~oop
**/

var L = Y.Lang,
A = Y.Array,
OP = Object.prototype,
Expand All @@ -39,110 +30,111 @@ function dispatch(o, f, c, proto, action) {
}
}

/**
Augments the _receiver_ with prototype properties from the _supplier_. The
receiver may be a constructor function or an object. The supplier must be a
constructor function.
If the _receiver_ is an object, then the _supplier_ constructor will be called
immediately after _receiver_ is augmented, with _receiver_ as the `this` object.
If the _receiver_ is a constructor function, then all prototype methods of
_supplier_ that are copied to _receiver_ will be sequestered, and the
_supplier_ constructor will not be called immediately. The first time any
sequestered method is called on the _receiver_'s prototype, all sequestered
methods will be immediately copied to the _receiver_'s prototype, the
_supplier_'s constructor will be executed, and finally the newly unsequestered
method that was called will be executed.
This sequestering logic sounds like a bunch of complicated voodoo, but it makes
it cheap to perform frequent augmentation by ensuring that suppliers'
constructors are only called if a supplied method is actually used. If none of
the supplied methods is ever used, then there's no need to take the performance
hit of calling the _supplier_'s constructor.
@method augment
@param {Function|Object} receiver Object or function to be augmented.
@param {Function} supplier Function that supplies the prototype properties with
which to augment the _receiver_.
@param {Boolean} [overwrite=false] If `true`, properties already on the receiver
will be overwritten if found on the supplier's prototype.
@param {String[]} [whitelist] An array of property names. If specified,
only the whitelisted prototype properties will be applied to the receiver, and
all others will be ignored.
@param {Array|any} [args] Argument or array of arguments to pass to the
supplier's constructor when initializing.
@return {Function} Augmented object.
**/
Y.augment = function (receiver, supplier, overwrite, whitelist, args) {
var rProto = receiver.prototype,
sequester = rProto && supplier,
sProto = supplier.prototype,
to = rProto || receiver,

copy,
newPrototype,
replacements,
sequestered,
unsequester;

args = args ? Y.Array(args) : [];

if (sequester) {
newPrototype = {};
replacements = {};
sequestered = {};

copy = function (value, key) {
if (overwrite || !(key in rProto)) {
if (toString.call(value) === '[object Function]') {
sequestered[key] = value;

newPrototype[key] = replacements[key] = function () {
return unsequester(this, value, arguments);
};
} else {
newPrototype[key] = value;
}
/**
Augments the _receiver_ with prototype properties from the _supplier_. The
receiver may be a constructor function or an object. The supplier must be a
constructor function.
If the _receiver_ is an object, then the _supplier_ constructor will be called
immediately after _receiver_ is augmented, with _receiver_ as the `this` object.
If the _receiver_ is a constructor function, then all prototype methods of
_supplier_ that are copied to _receiver_ will be sequestered, and the
_supplier_ constructor will not be called immediately. The first time any
sequestered method is called on the _receiver_'s prototype, all sequestered
methods will be immediately copied to the _receiver_'s prototype, the
_supplier_'s constructor will be executed, and finally the newly unsequestered
method that was called will be executed.
This sequestering logic sounds like a bunch of complicated voodoo, but it makes
it cheap to perform frequent augmentation by ensuring that suppliers'
constructors are only called if a supplied method is actually used. If none of
the supplied methods is ever used, then there's no need to take the performance
hit of calling the _supplier_'s constructor.
@method augment
@param {Function|Object} receiver Object or function to be augmented.
@param {Function} supplier Function that supplies the prototype properties with
which to augment the _receiver_.
@param {Boolean} [overwrite=false] If `true`, properties already on the receiver
will be overwritten if found on the supplier's prototype.
@param {String[]} [whitelist] An array of property names. If specified,
only the whitelisted prototype properties will be applied to the receiver, and
all others will be ignored.
@param {Array|any} [args] Argument or array of arguments to pass to the
supplier's constructor when initializing.
@return {Function} Augmented object.
@for YUI
**/
Y.augment = function (receiver, supplier, overwrite, whitelist, args) {
var rProto = receiver.prototype,
sequester = rProto && supplier,
sProto = supplier.prototype,
to = rProto || receiver,

copy,
newPrototype,
replacements,
sequestered,
unsequester;

args = args ? Y.Array(args) : [];

if (sequester) {
newPrototype = {};
replacements = {};
sequestered = {};

copy = function (value, key) {
if (overwrite || !(key in rProto)) {
if (toString.call(value) === '[object Function]') {
sequestered[key] = value;

newPrototype[key] = replacements[key] = function () {
return unsequester(this, value, arguments);
};
} else {
newPrototype[key] = value;
}
};
}
};

unsequester = function (instance, fn, fnArgs) {
// Unsequester all sequestered functions.
for (var key in sequestered) {
if (hasOwn.call(sequestered, key)
&& instance[key] === replacements[key]) {
unsequester = function (instance, fn, fnArgs) {
// Unsequester all sequestered functions.
for (var key in sequestered) {
if (hasOwn.call(sequestered, key)
&& instance[key] === replacements[key]) {

instance[key] = sequestered[key];
}
instance[key] = sequestered[key];
}
}

// Execute the supplier constructor.
supplier.apply(instance, args);
// Execute the supplier constructor.
supplier.apply(instance, args);

// Finally, execute the original sequestered function.
return fn.apply(instance, fnArgs);
};
// Finally, execute the original sequestered function.
return fn.apply(instance, fnArgs);
};

if (whitelist) {
Y.Array.each(whitelist, function (name) {
if (name in sProto) {
copy(sProto[name], name);
}
});
} else {
Y.Object.each(sProto, copy, null, true);
}
if (whitelist) {
Y.Array.each(whitelist, function (name) {
if (name in sProto) {
copy(sProto[name], name);
}
});
} else {
Y.Object.each(sProto, copy, null, true);
}
}

Y.mix(to, newPrototype || sProto, overwrite, whitelist);
Y.mix(to, newPrototype || sProto, overwrite, whitelist);

if (!sequester) {
supplier.apply(to, args);
}
if (!sequester) {
supplier.apply(to, args);
}

return receiver;
};
return receiver;
};

/**
* Applies object properties from the supplier to the receiver. If
Expand Down Expand Up @@ -206,7 +198,7 @@ Y.extend = function(r, s, px, sx) {
/**
* Executes the supplied function for each item in
* a collection. Supports arrays, objects, and
* Y.NodeLists
* NodeLists
* @method each
* @param {object} o the object to iterate.
* @param {function} f the function to execute. This function
Expand All @@ -224,7 +216,7 @@ Y.each = function(o, f, c, proto) {
* Executes the supplied function for each item in
* a collection. The operation stops if the function
* returns true. Supports arrays, objects, and
* Y.NodeLists.
* NodeLists.
* @method some
* @param {object} o the object to iterate.
* @param {function} f the function to execute. This function
Expand All @@ -240,7 +232,7 @@ Y.some = function(o, f, c, proto) {
};

/**
* Deep obj/array copy. Function clones are actually
* Deep object/array copy. Function clones are actually
* wrappers around the original function.
* Array-like objects are treated as arrays.
* Primitives are returned untouched. Optionally, a
Expand Down
Loading

0 comments on commit 7c7d811

Please sign in to comment.