From 47188b792617a0030ccec07c6df27335dc3aa430 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 16 Jul 2015 09:13:15 -0400 Subject: [PATCH] Core: Move escape selector into its own module Ref #9647 --- ui/core.js | 11 ++--------- ui/escape-selector.js | 21 +++++++++++++++++++++ ui/selectmenu.js | 1 + ui/tabs.js | 1 + 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 ui/escape-selector.js diff --git a/ui/core.js b/ui/core.js index a0931dffa..fe627dea6 100644 --- a/ui/core.js +++ b/ui/core.js @@ -22,6 +22,7 @@ "jquery", "./data", "./disable-selection", + "./escape-selector", "./focusable", "./version" ], factory ); @@ -90,15 +91,7 @@ $.extend( $.ui, { if ( element && element.nodeName.toLowerCase() !== "body" ) { $( element ).trigger( "blur" ); } - }, - - // Internal use only - escapeSelector: ( function() { - var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g; - return function( selector ) { - return selector.replace( selectorEscape, "\\$1" ); - }; - } )() + } } ); // plugins diff --git a/ui/escape-selector.js b/ui/escape-selector.js new file mode 100644 index 000000000..d43e4f816 --- /dev/null +++ b/ui/escape-selector.js @@ -0,0 +1,21 @@ +( function( factory ) { + if ( typeof define === "function" && define.amd ) { + + // AMD. Register as an anonymous module. + define( [ "jquery", "./version" ], factory ); + } else { + + // Browser globals + factory( jQuery ); + } +} ( function( $ ) { + +// Internal use only +return $.ui.escapeSelector = ( function() { + var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g; + return function( selector ) { + return selector.replace( selectorEscape, "\\$1" ); + }; +} )(); + +} ) ); diff --git a/ui/selectmenu.js b/ui/selectmenu.js index 227d87ae7..fe1a7fa99 100644 --- a/ui/selectmenu.js +++ b/ui/selectmenu.js @@ -24,6 +24,7 @@ "jquery", "./core", "./version", + "./escape-selector", "./widget", "./position", "./menu" diff --git a/ui/tabs.js b/ui/tabs.js index 5aaa8c5fa..4cd80a1df 100644 --- a/ui/tabs.js +++ b/ui/tabs.js @@ -23,6 +23,7 @@ define( [ "jquery", "./core", + "./escape-selector", "./version", "./widget" ], factory ); -- 2.39.5