5

Lightning Locker seems to be causing major issues with the jQuery selector and find actions (and by extension most other jQuery functions). Certain errors were arising due to jQuery 2.1.4 that are resolved by upgrading to jQuery 2.2.4. But jQuery 2.2.4 is generating the "Cannot redefine property:title" error. For some people those errors are resolved by using the correct ltng:require syntax, but that doesn't seem to be helping with these jQuery errors.

The error is related to how Lightning's Locker Service wraps html elements and permits or restricts certain operations on them. Even after upgrading to jQuery 2.2.4, certain jQuery actions like .bind, .on, .click, .length, .change, .keyup, .show, .hide, .each, etc. My workaround has been to use JavaScript alternatives to these problematic jQuery commands, with the advice from http://youmightnotneedjquery.com/. The specific function within LockerService that triggers this is SecureObject.$addIfSupported$ when it receives a name parameter of "title". It's triggered by jQuery's find and select methods which underlie most other jQuery commands. I'm hoping that the Locker team can weigh in to help with this.

This seems closely tied to this issue, which shows how the error relates to the version of jQuery used.

2
  • @DougChasman - any ideas?
    – abd3721
    Commented Jul 4, 2016 at 23:06
  • 2
    I can confirm I can reproduce this. Digging more to see what's going on here. Commented Jul 5, 2016 at 6:34

2 Answers 2

1

Fix for this has been identified and scheduled for the next available patch to Summer'16. The fix is trivial and has nothing to do with jQuery and everything to do with elements - the error is quite correct and LS code is attempting to Object.defineProperty("title") 2X inside of SecureElement because LINK's element specific property list already included "title" and at some point "title" was also added to the default set of properties resulting in this regression.

1
  • Certainly - fix is in and will be deployed to the service starting Tuesday Commented Jul 20, 2016 at 19:38
0

This happens when you use old JQuery resource (previous releases from 2016 & earlier).

Use the latest version of Jquery.min.js as resource & issue will be resolved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .