这是indexloc提供的服务,不要输入任何密码
Skip to content

Incompatibility between polyfill and plugin #52

@Unknown-Robot

Description

@Unknown-Robot

Hi Andrey,

Well, currently your polyfill uses the HTML <body> 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 <head> in your README, but if you do this you'll get an error, because if the polyfill is injected into the <head> at runtime the <body> 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 <html> 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 <body> element.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions