Bootstrap-select: Sanitizer throws: `bootstrap-select.js:1250 Uncaught TypeError: Cannot read property 'data' of undefined`

Created on 13 Mar 2019  Â·  9Comments  Â·  Source: snapappointments/bootstrap-select

Howdy!

Error

Uncaught TypeError: Cannot read property 'data' of undefined
    at scroll (bootstrap-select.js:1250)
    at Selectpicker.createView (bootstrap-select.js:1125)
    at Selectpicker.setSize (bootstrap-select.js:2010)
    at HTMLButtonElement.<anonymous> (bootstrap-select.js:2303)
    at HTMLButtonElement.dispatch (jquery-3.3.1.min.js?1292635420:2)
    at HTMLButtonElement.y.handle (jquery-3.3.1.min.js?1292635420:2)
              if (that.options.sanitize) {
                elText = element.lastChild;

                if (elText) {
                  elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0].data;

                  if (elementData && elementData.content && !elementData.sanitized) {
                    toSanitize.push(elText);
                    elementData.sanitized = true;
                  }
                }
>             }



md5-9b76dd97b623ac8a187a5adb9b652e62



array:78 [â–¼
  2887 => ""
  2890 => ""
  2893 => ""
  2896 => ""
  2899 => ""
  2902 => ""
  2905 => ""
  2908 => ""
  2911 => ""
  2914 => ""
  2917 => ""
  2920 => ""
  2923 => ""
  2926 => ""
  2929 => ""
  2845 => ""
  2782 => ""
  1583 => ""
  2710 => ""
  1918 => ""
  2717 => ""
  282 => ""
  2779 => ""
  2780 => ""
  2773 => ""
  2786 => ""
  2666 => ""
  2787 => ""
  1674 => ""
  2719 => ""
  3022 => ""
  2770 => ""
  1539 => ""
  3031 => ""
  229 => ""
  152 => ""
  129 => ""
  2776 => ""
  2777 => ""
  390 => ""
  153 => ""
  2944 => ""
  2774 => ""
  760 => ""
  406 => ""
  2718 => ""
  2778 => ""
  2783 => ""
  1820 => ""
  1885 => ""
  942 => ""
  2715 => ""
  2643 => ""
  2738 => ""
  2771 => ""
  2772 => ""
  2753 => ""
  131 => ""
  250 => ""
  1915 => ""
  128 => ""
  949 => ""
  1575 => ""
  2711 => ""
  130 => ""
  1621 => ""
  413 => ""
  234 => ""
  283 => ""
  245 => ""
  246 => ""
  1566 => ""
  1568 => ""
  940 => ""
  154 => ""
  2076 => ""
  1346 => ""
  1825 => ""
]

Regards.

Most helpful comment

Released in v1.13.8!

All 9 comments

Can you give me some more info about your setup? I've recreated your select based on what you've told me and it's working fine here: https://plnkr.co/edit/EiAVvxRMD1XoS1UgYWQZ?p=preview.

Bug reports must include a live demo of the problem (please feel free to use my linked Plunker for your reduced test case). I also need your:

  • Bootstrap version
  • specific browser and OS details.

I am facing same issue .
Uncaught TypeError: Cannot read property 'data' of undefined

Exactly error in this line
elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0].data;
line no. 1260
"bootstrap-select": "^1.13.6",
"jquery": "^3.3.1",
"bootstrap": "^4.3.1",

Bootstrap v3.3.7
jQuery v3.3.1
Chrome v72.0.3626.121
Win10 x64

               element.selectpicker({
                    dropupAuto: false, // Always drop to bottom
                    noneSelectedText: typeof lang !== 'undefined' ? lang.common.please_select
                        : null, // Apply polite placeholder
                });

I am facing the same issue. I could reproduce the issue in an Plnkr environment: https://next.plnkr.co/edit/R4sSYX1zoUrbggGK (sry, i have tried to shorten it, but if i cut some more option tags, then the bug does not occur)

The error seems only to occur, when one of the middle options is selected. I would guess this bug is somehow related to the position of the selected option in the select element...

Yes I can confirm that when I removed the option which was selected then the bug was not appearing. But not sure what does this mean.

Released in v1.13.8!

I have the same issue and i just updated it to new plunker.
https://plnkr.co/edit/gGsG7IV0EdRVLtYr kindly look around it and help me to get a solution.

@kvvaradha I'm not seeing that error in that Plunker. What are the steps to reproduce?

Was this page helpful?
0 / 5 - 0 ratings