walinejs / waline

💬 A Simple, Safe Comment System
https://waline.js.org/en/
GNU General Public License v2.0
2.19k stars 379 forks source link

[BUG] 博客首页加载报错 Option 'el' is invalid! #308

Closed clay-world closed 3 years ago

clay-world commented 3 years ago

问题描述 | Describe the bug

使用最新的 Waline Client v1.2.3,首页加载报错,提示 Option 'el' is invalid!,Hexo 主题是 NexT 8.5

问题网站 | Website URL

部署方式 | Deploy Type

Mister-Hope commented 3 years ago

This is expected if you don't have a comment box in homepage while you still provide a el.

Just an error msg.

Mister-Hope commented 3 years ago

@lizheming Could you try to remove the el option when visiting home page in the official plugin?

lizheming commented 3 years ago

@Mister-Hope I think add try...catch at here is better than handle it outside of client script.

https://github.com/walinejs/waline/blob/main/packages/client/src/index.ts#L61-L63

try {
  const root = document.querySelector<HTMLElement>(el);
  return root || null;
} catch() {
  return null;
}
Mister-Hope commented 3 years ago

No need, the error log is logged by me with purpose.

I just want to warn the user their options is not correct.

lizheming commented 3 years ago

I think that's better to use console.warn() instead of console.error() if you just want to notice user.

Mister-Hope commented 3 years ago

Warning instead of error will be logged in v1.3.0+