d7_to_d10_migration/drupal7/web/misc/ui/jquery.ui.position-1.13.0-backport.js
Mauricio Dinarte 1664d5cfe6 Initial commit
2024-07-22 21:38:34 -06:00

33 lines
935 B
JavaScript

/**
* Backport of security fix from:
* https://github.com/jquery/jquery-ui/pull/1955/files
*/
(function ($) {
// No backport is needed if we're already on jQuery UI 1.13 or higher.
var versionParts = $.ui.version.split('.');
var majorVersion = parseInt(versionParts[0]);
var minorVersion = parseInt(versionParts[1]);
if ( (majorVersion > 1) || (majorVersion === 1 && minorVersion >= 13) ) {
return;
}
var fnOriginalPosition = $.fn.position;
$.fn.extend({
'position': function (options) {
if (typeof options === 'undefined') {
return fnOriginalPosition.call(this);
}
// Make sure string options are treated as CSS selectors
var target = typeof options.of === "string" ?
$(document).find(options.of) :
$(options.of);
options.of = (target[0] === undefined) ? null : target;
return fnOriginalPosition.call(this, options);
}
});
})(jQuery);