Sha256: 6c3256e9fff87f118eb9709b1c2cca43176e46c4004613f03c25e0a8573b61d5

Contents?: true

Size: 1.5 KB

Versions: 36

Compression:

Stored size: 1.5 KB

Contents

require 'set'
module Sass
  # Provides `Sass.has_feature?` which allows for simple feature detection
  # by providing a feature name.
  module Features
    # This is the set of features that can be detected.
    #
    # When this is updated, the documentation of `feature-exists()` should be
    # updated as well.
    KNOWN_FEATURES = Set[*%w{
      global-variable-shadowing
      extend-selector-pseudoclass
      units-level-3
      at-error
    }]

    # Check if a feature exists by name. This is used to implement
    # the Sass function `feature-exists($feature)`
    #
    # @param feature_name [String] The case sensitive name of the feature to
    #   check if it exists in this version of Sass.
    # @return [Boolean] whether the feature of that name exists.
    def has_feature?(feature_name)
      KNOWN_FEATURES.include?(feature_name)
    end

    # Add a feature to Sass. Plugins can use this to easily expose their
    # availability to end users. Plugins must prefix their feature
    # names with a dash to distinguish them from official features.
    #
    # @example
    #   Sass.add_feature("-import-globbing")
    #   Sass.add_feature("-math-cos")
    #
    #
    # @param feature_name [String] The case sensitive name of the feature to
    #   to add to Sass. Must begin with a dash.
    def add_feature(feature_name)
      unless feature_name[0] == ?-
        raise ArgumentError.new("Plugin feature names must begin with a dash")
      end
      KNOWN_FEATURES << feature_name
    end
  end

  extend Features
end

Version data entries

36 entries across 34 versions & 4 rubygems

Version Path
sass-3.4.21 lib/sass/features.rb
sass-4.0.0.alpha.1 lib/sass/features.rb
sass-3.4.20 lib/sass/features.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/features.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sass-3.4.18/lib/sass/features.rb
sass-3.4.19 lib/sass/features.rb
sass-3.4.18 lib/sass/features.rb
sass-3.4.17 lib/sass/features.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/sass-3.4.15/lib/sass/features.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/sass-3.4.15/lib/sass/features.rb
sass-3.4.16 lib/sass/features.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sass-3.4.14/lib/sass/features.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sass-3.4.15/lib/sass/features.rb
sass-3.4.15 lib/sass/features.rb
sass-3.4.14 lib/sass/features.rb
sass-3.4.13 lib/sass/features.rb
sass-3.4.12 lib/sass/features.rb
sass-3.4.11 lib/sass/features.rb
sass-3.4.10 lib/sass/features.rb
sass-3.4.9 lib/sass/features.rb