Export button breaks for NULL-data in a cell

Export button breaks for NULL-data in a cell

Inso2008Inso2008 Posts: 5Questions: 3Answers: 0

Hello, I'm seeing a possible regression in Buttons version 3.2.1.
The affected function is export buttons (tested with excelHtml5).

The problem is that a cell with its data == NULL shows correctly in browser (empty), but breaks the export.

Conditions for reproduction:
* Data with NULL in some column; this column does not define defaultContent nor render function.
* The export button does not redefine (uses the default) config.exportOptions.format.body (and .header and .footer)

The nature of the problem:
* Buttons v. 3.2.1 introduces smarter parsing of data: the function Buttons.stripData has new logic for handling data that is an instance of Node.
* The condition that checks for Node evaluates the expression (typeof str === 'object' && str.nodeName && str.nodeType)
* When NULL is passed, its typeof is 'object', but the further tests fail on (NULL).nodeName.

What to do?:
* Maybe NULL-data in a table isn't nice, but it did work with earlier versions of export buttons, and does work in display, and so arguably it should still work now. :D
* Expanding the Node-testing expression to (typeof str === 'object' && str && str.nodeName && str.nodeType) should restore the earlier behaviour for NULL-data (return NULL).

Answers

  • allanallan Posts: 63,966Questions: 1Answers: 10,547 Site admin

    I committed this change last week which should fix it.

    Are you able to try the nightly and see if that fixes it for you?

    Allan

  • Inso2008Inso2008 Posts: 5Questions: 3Answers: 0

    Great! That is the fix. Thank you.

  • allanallan Posts: 63,966Questions: 1Answers: 10,547 Site admin

    Awesome - I'll get it packaged up and released shortly.

    Allan

Sign In or Register to comment.