Giter Site home page Giter Site logo

Use external polyfills about object-fit HOT 16 CLOSED

anselmh avatar anselmh commented on July 30, 2024
Use external polyfills

from object-fit.

Comments (16)

TrySound avatar TrySound commented on July 30, 2024

closest is good for elements.matches.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

For "copy-lib" you may build bundle. For package managers build just core file and maybe getMatchedCSSRules polyfill. Other polyfills will be loaded as dependencies.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

Using closest will a little increase performance.

from object-fit.

anselmh avatar anselmh commented on July 30, 2024

Hi, thanks for the suggestions. I agree this could be done and have replaced the rAF polyfill with the one from npm.

I’ll see if I can make use of the closest polyfill and if it makes sense to use it here. Thanks for the hint.

For "copy-lib" you may build bundle. For package managers build just core file and maybe getMatchedCSSRules polyfill. Other polyfills will be loaded as dependencies.

Not sure what you mean here though? Can you explain this a bit more in detail perhaps?

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

I meant cdn libs or copying directly in project folder.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

Also add rAF to bower, please.

from object-fit.

anselmh avatar anselmh commented on July 30, 2024

Thanks so far for your suggestions. It seems the polyfill is indeed a bit faster now again. I’ll see if I can make the dependency stuff a bit less messy.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

@anselmh Are you sure you need el.closest, not el.matches? closest polyfills both.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

And rAF is not devDep

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

Closest is not devDependency too.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

Nice! I asked Jonathan Neal to publish closest on npm.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

@anselmh Closest added to npm
https://www.npmjs.com/package/element-closest

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

@anselmh Are you sure you need el.closest instead of el.matches? closest polyfills both.

from object-fit.

anselmh avatar anselmh commented on July 30, 2024

Thanks. Fixed to use the npm version now. Therefore closing this issue for now.

@anselmh Are you sure you need el.closest instead of el.matches? closest polyfills both.

I tested this and it didn’t fail while speeding up the polyfill. That’s why. If there’s any issue with it it’s easy to roll back.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

@anselmh It works. But el.closest do some more work. It checks current or finds closest parent element with this selector. Better use el.matches.

from object-fit.

TrySound avatar TrySound commented on July 30, 2024

@anselmh Prefomance, heh))

from object-fit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.