4

I'm having issues with jQuery Datatables in a lightning component. I just tested on a Spring 17 sandbox. I'm getting this error thrown when the datatable tries to initialize. I'm using jQuery v2.2.4 and jQuery datatables v1.10.11

enter image description here

I have quite a few lightning components running in production environments using jQuery Datatables, and I want to make sure that everything will work nicely when the Locker Service update is mandatory in the Summer 17 release.

Any help or suggestions will be greatly appreciated!

  • 1
    Realistically, you're going to want to ditch DataTables. There's no guarantee it'll be working in five months. Besides, sorting, pagination, and filtering are trivial in Lightning. I wrote two of the three in less than a work day, and if I'd thought about it, I'm sure I could have done all three at once in a day. Lightning is meant to replace jQuery, and it largely does. Personally, I'd advise against using jQuery for such trivial purposes. – sfdcfox Jan 7 '17 at 6:50
  • @sfdcfox Well I can agree most part of it, but I believe Lightning is never meant to replace jQuery, there are lots of difference between them. As you know, Lightning is a JS Framework which enforces lots of stuffs you should do to work on it whereas jQuery is a utility library whose primary goal to ease DOM Manipulation. With that said, I see no harm in using jquery datatable in LC, you can do so much with it. Using 3rd party libraries with Locker enabled is bit noisy at the moment, I believe things will get better with each release. – Praveen Jan 7 '17 at 17:34
3

This is the first report of this specific issue - Locker's design is required to be secure by default and the issue is that the name attribute is only supported on a subset of DOM elements:

https://developer.mozilla.org/en-US/docs/Web/API/Element/name

and that set does not include HTMLTableSectionElement. Locker's secure virtual DOM is not as permissive about setting nonsensical attributes as browsers are.

Technically this is a bug in Datatable.

I believe the fix for this will be to treat this as a pseudo standard and simply add name universally to our metadata (whitelist) for HTMLElememt.

Do you already have a support case open for this?

  • 1
    I have not opened a support case for this. Could you point me to where I would open a case? – Derek Hall Jan 7 '17 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.