colReorder inconsistent javascript files?

colReorder inconsistent javascript files?

xtech_devxtech_dev Posts: 25Questions: 11Answers: 0
edited September 2020 in Free community support

https://cdn.datatables.net/colreorder/1.5.2/js/dataTables.colReorder.min.js
vs https://cdn.datatables.net/colreorder/1.5.2/js/dataTables.colReorder.js

Using unminified version (dataTables.colReorder.js) results an exception in my case:
colReorder.js:177 Uncaught TypeError: Cannot create property '0' on number '2'
at jQuery.fn.init.$.fn.dataTableExt.oApi.fnColReorder (colReorder.js:177)
at jQuery.fn.init.fnColReorder (datatables.js:15014)

Using minified version (dataTables.colReorder.min.js) is fine.

When I manually compress/minify (dataTables.colReorder.js) exception still occurs. So I suspect that release files are inconsistent.

Please confirm do your experience same issues.

It Man.

Answers

  • xtech_devxtech_dev Posts: 25Questions: 11Answers: 0

    Got the difference. In minified version strict mode is skipped. Is it intended?

    ...
    }(function ($, window, document, undefined) {
        'use strict'; // this statement is excluded from minified vesion
        var DataTable = $.fn.dataTable;
    
    
        /**
         * Switch the key value pairing of an index array to be value key (i.e. the old value is now the
         * key). For example consider [ 2, 0, 1 ] this would be returned as [ 1, 2, 0 ].
         *  @method  fnInvertKeyValues
         *  @param   array aIn Array to switch around
         *  @returns array
         */
        function fnInvertKeyValues(aIn) {
    ...
    

    In such case exception will not be raised on:
    171: oSettings.aaSorting[i][0] = aiInvertMapping[oSettings.aaSorting[i][0]];

    when oSettings.aaSorting[i] element is an number (in my case it is).

    It Man

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    I'm not seeing that happen in this example.

    Could you link to a test case showing the initial error please?

    Probably it shouldn't remove `'use strict'; but I think that is just masking something else in this case.

    Thanks,
    Allan

This discussion has been closed.