From d0cc44635ef5c6b05df1244bb0241ed99e8c9ecc Mon Sep 17 00:00:00 2001 From: mmikitka Date: Wed, 13 Mar 2013 09:24:25 -0400 Subject: [PATCH] Made the noConflict() check more robust. Now works when Zepto is in noConflict-like mode. --- js/foundation/foundation.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/js/foundation/foundation.js b/js/foundation/foundation.js index 5f6f8c1aa..d4246f58a 100644 --- a/js/foundation/foundation.js +++ b/js/foundation/foundation.js @@ -8,11 +8,21 @@ /*jslint unparam: true, browser: true, indent: 2 */ -// Accommodate running jQuery in noConflict() mode by -// using an anonymous function to redefine the jQuery $ -// shorthand name. See http://docs.jquery.com/Using_jQuery_with_Other_Libraries -if (jQuery == null) { - var jQuery = $; +// Accommodate running jQuery or Zepto in noConflict() mode by +// using an anonymous function to redefine the $ shorthand name. +// See http://docs.jquery.com/Using_jQuery_with_Other_Libraries +// and http://zeptojs.com/ +var libFuncName = null; +if (typeof jQuery === "undefined" && + typeof Zepto === "undefined" && + typeof $ === "function") { + libFuncName = $; +} else if (typeof jQuery === "function") { + libFuncName = jQuery; +} else if (typeof Zepto === "function") { + libFuncName = Zepto; +} else { + throw new TypeError(); } (function ($) { @@ -339,4 +349,4 @@ if (jQuery == null) { }(this, this.document)); -})(jQuery); +})(libFuncName); -- 2.47.3