Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

string.replace is not a function #1790

Closed
Nesse opened this issue Sep 2, 2016 · 3 comments
Closed

string.replace is not a function #1790

Nesse opened this issue Sep 2, 2016 · 3 comments

Comments

@Nesse
Copy link

Nesse commented Sep 2, 2016

When I try to use the latest jQuery version (3.1.0) together with jQuery Migrate (3.0.0) I get the following error:

angular.js:13236 TypeError: string.replace is not a function
at Function.camelCase (jquery-3.1.0.js:355)
at Function.jQuery.data (jquery-migrate-3.0.0.js:306)
at replaceWith (angular.js:9466)
at angular.js:9177
at processQueue (angular.js:15552)
at angular.js:15568
at Scope.$eval (angular.js:16820)
at Scope.$digest (angular.js:16636)
at Scope.$apply (angular.js:16928)
at bootstrapApply (angular.js:1694)

http://run.plnkr.co/Dhsbj67CMvE40tQW/

Is it possible to use ui-select along with jQuery and jQuery Migrate?

@user378230
Copy link
Contributor

jQuery is only required to support legacy browsers.

If you want to submit a PR to resolve jQuery compatibility issues feel free but it isn't a requirement for this project.

@acetrand
Copy link

acetrand commented Sep 16, 2016

@Nesse
We had a similar problem and the issue lies in the migrate plugin. Angular uses jQuery.data() internally and sometimes it passes a scope object for the name argument.

// jquery-migrate-3.js
...
jQuery.data = function( elem, name, value ) {    // sometimes name is a scope object here
    var curData;

    // If the name is transformed, look for the un-transformed name in the data object
    if ( name && typeof name === "string" && name !== jQuery.camelCase( name ) ) {   // << added type check
        curData = jQuery.hasData( elem ) && oldData.call( this, elem );
...

Try adding a typeofcheck in the if to make sure the migrate plugin only warns if the name actually is a string.

@kinsho
Copy link

kinsho commented Jan 5, 2017

@acetrand
Thank you for the clarification. I spent a good chunk of time trying to figure out exactly why this error was coming about.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants