ai / ai/webp-in-css

Incompatibility between polyfill and plugin

オープン
#52 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
343
フォーク
26
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi Andrey,

Well, currently your polyfill uses the HTML `` element to inject the .webp or .no-webp class, depending on whether the browser is compatible or not.

You specify `Polyfill should be inserted in the ` in your README, but if you do this you'll get an error, because if the polyfill is injected into the `` at runtime the `` element doesn't yet exist you'll get an error like this :

`Uncaught TypeError: Cannot read properties of null (reading 'classList')`

I suggest replacing `document.body` in the polyfill.js file with `document.documentElement` in order to use the `` element for .webp or .no-webp class injection. There are a few logical changes to be made in the plugin.js file, and I'd be happy to make a pull request to fix the problem, or if you'd like to do it yourself.

If I've missed any information, please let me know. There may be a reason why you're using the `` element.

Thanks

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。