Sha256: d287d8a57e038e10426bfe6829fb4794f7928a7ffbb976675ceac474cdd2e6a1

Contents?: true

Size: 1.5 KB

Versions: 32

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

32 entries across 31 versions & 4 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.4.0 bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/sass-3.4.25/lib/sass/features.rb
sass-3.4.25 lib/sass/features.rb
brakeman-3.7.0 bundle/ruby/2.3.0/gems/sass-3.4.24/lib/sass/features.rb
brakeman-3.6.2 bundle/ruby/2.3.0/gems/sass-3.4.24/lib/sass/features.rb
sass-3.4.24 lib/sass/features.rb
brakeman-3.6.1 bundle/ruby/2.3.0/gems/sass-3.4.23/lib/sass/features.rb
brakeman-3.6.0 bundle/ruby/2.3.0/gems/sass-3.4.23/lib/sass/features.rb
brakeman-3.5.0 bundle/ruby/2.3.0/gems/sass-3.4.23/lib/sass/features.rb