Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noConflict causes issue with deprecated methods #2705

Open
inneslu opened this issue Jul 29, 2024 · 0 comments
Open

noConflict causes issue with deprecated methods #2705

inneslu opened this issue Jul 29, 2024 · 0 comments

Comments

@inneslu
Copy link

inneslu commented Jul 29, 2024

Expected behaviour

Deprecated function should run it's alias, and not error. Deprecated message should appear in console.

Actual behaviour

Error is thrown; $.fn.datepicker.deprecated not a function

Datepicker version used

1.8 - however, issue is still present in latest version - if any methods use the deprecated message.

Example code

var datepicker = $.fn.datepicker.noConflict();
$.fn.bootstrapDP = datepicker;

$('.datepicker').bootstrapDP({options});
$('.datepicker').bootstrapDP('remove');

Reason why issue is occuring

Deprecated function is being assigned to datepicker:

$.fn.datepicker.deprecated = function(msg){
		var console = window.console;
		if (console && console.warn) {
			console.warn('DEPRECATED: ' + msg);
		}
	};

No conflict is reverting the datepicker function:

$.fn.datepicker.noConflict = function(){
		$.fn.datepicker = old;
		return this;
	};

Alias function is referring to datepicker - which has since been reverted (i.e. no deprecated function exists):

function alias(method, deprecationMsg){
		return function(){
			if (deprecationMsg !== undefined) {
				$.fn.datepicker.deprecated(deprecationMsg);
			}

			return this[method].apply(this, arguments);
		};
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant