Author: hlship Date: Sat Aug 6 02:55:10 2011 New Revision: 1154436 URL: http://svn.apache.org/viewvc?rev=1154436&view=rev Log: Clean up a few more places to use Underscore rather than Prototype or ad-hoc JavaScript
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js?rev=1154436&r1=1154435&r2=1154436&view=diff ============================================================================== --- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js (original) +++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js Sat Aug 6 02:55:10 2011 @@ -35,12 +35,11 @@ var T5 = { * @returns the destination object */ extend : function(destination, source) { - if (typeof source == "function") { + if (_.isFunction(source)) { source = source(); } - // Prototype: - return Object.extend(destination, source); + return _.extend(destination, source); }, /** Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js?rev=1154436&r1=1154435&r2=1154436&view=diff ============================================================================== --- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js (original) +++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js Sat Aug 6 02:55:10 2011 @@ -1,44 +1,5 @@ var JST = (function() { - /* - * Original script title/version: Object.identical.js/1.11 Copyright (c) - * 2011, Chris O'Brien, prettycode.org - * http://github.com/prettycode/Object.identical.js - * - * LICENSE: Permission is hereby granted for unrestricted use, modification, - * and redistribution of this script, ONLY under the condition that this - * code comment is kept wholly complete, appearing above the script's code - * body--in all original or modified implementations of this script, except - * those that are minified. - */ - - /* - * Requires ECMAScript 5 functions: - Array.isArray() - Object.keys() - - * Array.prototype.forEach() - JSON.stringify() - */ - - function identical(a, b, sortArrays) { - - function sort(o) { - - if (sortArrays === true && Array.isArray(o)) { - return o.sort(); - } else if (typeof o !== "object" || o === null) { - return o; - } - - var result = {}; - - Object.keys(o).sort().forEach(function(key) { - result[key] = sort(o[key]); - }); - - return result; - } - - return JSON.stringify(sort(a)) === JSON.stringify(sort(b)); - } - var resultElement; var $fail = {}; @@ -54,6 +15,7 @@ var JST = (function() { function toString(value) { + // Prototype: return Object.toJSON(value); } @@ -69,7 +31,7 @@ var JST = (function() { function assertEqual(actual, expected) { - if (!identical(actual, expected)) { + if (!_.isEqual(actual, expected)) { failNotEqual(actual, expected); } }