Illegal invocation at elementClosest fullcalendar v4.3.1

huangapple go评论81阅读模式
英文:

Illegal invocation at elementClosest fullcalendar v4.3.1

问题

我使用了Salesforce LWC内的fullcalendar库v4.3.1。在沙箱中一切正常,直到我点击事件内部,然后出现以下错误:

aura_prod.js:999 Uncaught TypeError: Illegal invocation
throws at https://mybts--partial.sandbox.my.site.com/....../fullcalendar/packages/core/main.js:126:30 TypeError: Illegal invocation
    at elementClosest (main.js:126:30)
    at DateComponent.isValidDateDownEl (main.js:4070:25)
    at DateClicking._this.handlePointerDown (main.js:1128:57)
    at applyAll (main.js:988:36)
    at EmitterMixin.triggerWith (main.js:3523:17)
    at EmitterMixin.trigger (main.js:3518:18)
    at HitDragging.handlePointerDown (main.js:988:35)
    at applyAll (main.js:988:36)
    at EmitterMixin.triggerWith (main.js:3523:17)
    at EmitterMixin.trigger (main.js:3518:18)

我已经尝试了许多次其他线程上的解决方案(例如:https://github.com/fullcalendar/fullcalendar/issues/4990)。许多人分享了这个解决方案:

在core/main.js的第126行,将这个:

function elementClosest(el, selector) {
  return closestMethod.call(el, selector);
}

改为这个:

function elementClosest(el, selector) {
 return el.closest(selector);
}

但这个解决方案对我不起作用。当我上传带有此更改的库到静态资源时,会出现加载错误,fullcalendar库无法加载core/main.js。

我还尝试了其他版本,但都无法使其工作。有人能提供帮助吗?

从一个版本切换到另一个版本。

英文:

I'm using fullcalendar library v4.3.1 inside a Salesforce LWC. All was working good in sandbox until I clicked inside an event and I get the following error:

aura_prod.js:999 Uncaught TypeError: Illegal invocation
throws at https://mybts--partial.sandbox.my.site.com/....../fullcalendar/packages/core/main.js:126:30 TypeError: Illegal invocation
    at elementClosest (main.js:126:30)
    at DateComponent.isValidDateDownEl (main.js:4070:25)
    at DateClicking._this.handlePointerDown (main.js:1128:57)
    at applyAll (main.js:988:36)
    at EmitterMixin.triggerWith (main.js:3523:17)
    at EmitterMixin.trigger (main.js:3518:18)
    at HitDragging.handlePointerDown (main.js:988:35)
    at applyAll (main.js:988:36)
    at EmitterMixin.triggerWith (main.js:3523:17)
    at EmitterMixin.trigger (main.js:3518:18)

I've tried many times what I've found on other threads (for example: https://github.com/fullcalendar/fullcalendar/issues/4990). Many people has shared this solution:

At core/main.js line 126 change this:

function elementClosest(el, selector) {
  return closestMethod.call(el, selector);
}

To this:

function elementClosest(el, selector) {
 return el.closest(selector);
}

But that solution doesn't work for me. As I upload the library to the static resource with that change I get a loaded error and the fullcalendar library is not loaded as it can load the core/main.js.

I've tried also with other versions and I don't make it work.
Anyone can assist?

Change from a version to another.

答案1

得分: 1

解决方案
我已成功使这个工作。我刚意识到我没有正确设置静态源路径。

我确认此解决方案适用于lwc内的fullcalendar库。

在core/main.js的第126行更改为以下内容:

function elementClosest(el, selector) {
 return el.closest(selector);
}

然后,您可能需要对function elementMatches()做同样的事情,它就在function elementClosest()的下面。我不得不这样做,而且它起作用了:

将这个:

function elementMatches(el, selector) {
 return matchesMethod.call(el, selector);
}

改成这个:

function elementMatches(el, selector) {
 return el.matches(selector);
}
英文:

SOLUTION:
I’ve managed to get this works. I just realised I was not setting the path static source correctly.

I confirm this solution works for the fullcalendar library inside a lwc.

Change to this at line 126 of core/main.js:

function elementClosest(el, selector) {
 return el.closest(selector);
}

Then, you’ll probably have to do the same with function elementMatches() just below function elementClosest(). I had to do it and it worked:

Change this:

function elementMatches(el, selector) {
 return matchesMethod.call(el, selector);
}

To this:

function elementMatches(el, selector) {
 return el.matches(selector);
}

huangapple
  • 本文由 发表于 2023年3月4日 00:42:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75629731.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定