Uncaught TypeError: Cannot redefine property: title throws at …/aura_prod.js (Lightning Locker)

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.


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.

Source : Link , Question Author : abd3721 , Answer Author : Doug Chasman

Leave a Comment