Sha256: 35740807d5006f8e7909ad7febe49d206f54c65b31862889a016b8bed8f994cd

Contents?: true

Size: 1.53 KB

Versions: 27

Compression:

Stored size: 1.53 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
      custom-property
    )]

    # 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

27 entries across 27 versions & 3 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-3.7.4/lib/sass/features.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
sass-3.7.4 lib/sass/features.rb
sass-3.7.3 lib/sass/features.rb
sass-3.7.2 lib/sass/features.rb
sass-3.7.1 lib/sass/features.rb
sass-3.7.0 lib/sass/features.rb
sass-3.6.0 lib/sass/features.rb
sass-3.5.7 lib/sass/features.rb
sass-3.5.6 lib/sass/features.rb