'excelHtml5: Cannot read properties of null (reading 'nodeName') with Buttons 3.2.1 (3.2.0 works)

'excelHtml5: Cannot read properties of null (reading 'nodeName') with Buttons 3.2.1 (3.2.0 works)

LoFiLoFi Posts: 2Questions: 1Answers: 0

Debugger code (debug.datatables.net): ovanal
Error messages shown:
Uncaught TypeError: Cannot read properties of null (reading 'nodeName')
at Buttons.stripData
at Object.body
at _exportData
at X.<anonymous>
at Function.exportData
at X.action
at run

The error is here:
A.stripData = function(t, n) {
return "string" == typeof (t = "object" == typeof t && t.nodeName && t.nodeType ? t.innerHTML : t) && ...

Description of problem: I get this error using excelHtml5 with 3.2.1. 3.2.0 works as expected.

Answers

  • kthorngrenkthorngren Posts: 21,680Questions: 26Answers: 5,019

    Excel export works with this Buttons 3.2.1 test case:
    https://live.datatables.net/zizafopo/1/edit

    We will need more information to debug. Please provide a link to a test case showing the error. Feel free to update my test case.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • LoFiLoFi Posts: 2Questions: 1Answers: 0

    Many thanks for the super fast answer and many thanks for DataTable.
    I see that the null comes from the body and since I cannot guarantee that it doesn't happen again, I will add locally a check for str not null before toher checks since typeof str === "object" is true, if str is null, but in this case str.nodeName is invalid.

    Buttons.stripData = function (str, config) {
        // If the input is an HTML element, we can use the HTML from it (HTML might be stripped below).
        if (typeof str === 'object' && str.nodeName && str.nodeType) {
          str = str.innerHTML;
        }
    
        if (typeof str !== 'string') {
          return str;
        }
    

    regards

  • allanallan Posts: 64,015Questions: 1Answers: 10,555 Site admin

    Gah - bloody Javascript. Thanks for identifying that error. I've committed a change that will be in the next patch release.

    Allan

Sign In or Register to comment.