font.js javascript error when pasting from Google Doc

Created on 28 June 2023, over 1 year ago
Updated 30 June 2023, over 1 year ago

We are getting the following error on js/build/font.js when we paste from a Google Doc (which can contain spans)
Cannot read properties of undefined (reading 'replace')

This is being caused by this part of font.js:

    function $(e) {
      return (e) => e.getAttribute("data-color").replace(/\s/g, "");
    }

Proposal for a fix is to guard the e.getAttribute:


function $(e) {
  return (e) => {
    if (e && e.getAttribute && typeof e.getAttribute === "function") {
      const dataColor = e.getAttribute("data-color");
      if (dataColor) {
        return dataColor.replace(/\s/g, "");
      }
    }
    // Handle the case when the attribute or value is not present
    return null; // or any other appropriate default value
  };
}

Will provide a patch.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇳🇱Netherlands falco010 🇳🇱 The Netherlands

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024