1

While implementing cleave.js for credit card formatting of an input field created as a custom element using litElement I ran into this error when I type the first character into the input but no issue with subsequent characters.

cleave-esm.js:712 Uncaught TypeError: Cannot read property 'slice' of undefined
    at Object.getPostDelimiter (cleave-esm.js:712)
    at Cleave.onChange (cleave-esm.js:1244)

I tracked it down as far as that it seems getPostDelimiter() is taking a value that is the previous character typed. Since I am looking at the first character this function fails when it tries to execute cleave-esm.js:712.

return value.slice(-delimiter.length) === delimiter ? delimiter : '';

I'm not sure if there is something I can do in my implementation to resolve this or if it's just a bug in Cleave.js that needs to be fixed.

Progman
  • 16,827
  • 6
  • 33
  • 48
Capsule42
  • 11
  • 1

1 Answers1

0

It seems it's an issue introduced in 1.6.0 release.

If you can stick to a previous version, that should get you going.

MMalke
  • 1,857
  • 1
  • 24
  • 35