cascader icon indicating copy to clipboard operation
cascader copied to clipboard

querySelect报错

Open accwill opened this issue 3 years ago • 1 comments

https://github.com/react-component/cascader/blob/6ffd73324df75c915cf672aa14124c922f3b4d2a/src/OptionList/index.tsx#L157-L159

当代码中Selector中存在双引号时,代码将会抛出异常

  • 测试代码: document.querySelector('"asdlfjlksj"')

  • 异常信息如下所示

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '"asdlfjlksj"' is not a valid selector.

accwill avatar Dec 05 '22 07:12 accwill

      try {
        ele = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("li[data-path-key=\"".concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), "\"]"));
      } catch(e) {
      }

我暂时在我的代码中打了个补丁

accwill avatar Dec 05 '22 07:12 accwill