npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

support-for

v1.0.7

Published

Allows Sass authors to conditionally add support for specific browser versions.

Downloads

2,052

Readme

support-for

The support-for module allows Sass authors to conditionally add support for specific browser versions to their Sass module or Sass partials.

Autoprefixer is great for conditionally adding vendor prefixes, but sometimes you need more extensive CSS for specific versions of browsers. For example, adding px fallbacks to rem units when you need IE 8 support.

Authors of Sass code with support-for can specify which browser versions they want to support by setting a simple Sass variable, $support-for.

Here are some example usages:

  1. The Sass author only wants to support Safari 8 and later (and no other browsers) because he is an asshole.
 $support-for: (
   safari: 8,
   '*':    null, // null means "no support" and is the
                 // default value for any browser not
                 // specified in $support-for
 );

 // Normalize-scss uses support-for to conditionally
 // output CSS for old and new browsers.
 @import "normalize";
  1. The Sass author wants to support the 4 most recent versions of all browsers which she can do by setting the wildcard browser, '*'. She also has to support IE 6 and later because the client hates her.
 $support-for: (
   '*': -4,
   ie:  6,
 );

 @import "normalize";
  1. The Sass author is working for a government client and every browser version has a specific version specified in the contract.
 $support-for: (
   chrome:  29,
   edge:    20,
   firefox: 26,
   ie:      8,
   opera:   14,
   safari:  5,
 );

 @import "normalize";

By the way, here's the default value of $support-for:

// Support the last 4 versions of all browsers except IE.
$support-for: (
  chrome:  -4,
  edge:    -4,
  firefox: -4,
  ie:      9,
  opera:   -4,
  safari:  -4,
  '*':     -4,
) !default;

Update your Sass partials to use support-for()

If a Sass module tells you that it uses support-for, you just need to override the default value of the $support-for variable before you import that module. See the examples above to see some of your options.

If, however, you want to conditionally include Sass in the stylesheets you author, you can update your Sass code to wrap those lines of Sass with an @if block that uses the support-for() function.

@mixin my-sweet-sweet-mixin($cocoa: lots) {
  border-radius: 100%;

  // Only include this property if we support IE 10.
  @if support-for(ie, 10) {
    // Remove border when applied to an `img` inside an `a` element in IE 8/9/10.
    border: 0;
  }
}

If you later drop support for IE 10 (someday!), you just need to update the $support-for variable and your code will stop outputting the IE-10-specific CSS.

Updating your module to use support-for

If you are a Sass module author wanting to use support-for in your module, it's quite easy to add it as a dependency.

Ruby Sass

Alter your my-module.gemspec file:

  1. Find the line for your module's Sass dependency. It should look similar to this:
spec.add_runtime_dependency('sass', '~> 3.3')
  1. Just after that line, add this:
spec.add_runtime_dependency('support-for', '~> 1.0')

NPM (and node-sass)

Add your dependency with the following command:

npm install --save support-for

Bower

Add your dependency with the following command:

bower install --save support-for

Build Status