File: css_import_node.rb

package info (click to toggle)
ruby-sass 3.7.4-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,396 kB
  • sloc: ruby: 32,443; sh: 26; makefile: 25
file content (68 lines) | stat: -rw-r--r-- 2,141 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module Sass::Tree
  # A node representing an `@import` rule that's importing plain CSS.
  #
  # @see Sass::Tree
  class CssImportNode < DirectiveNode
    # The URI being imported, either as a plain string or an interpolated
    # script string.
    #
    # @return [String, Sass::Script::Tree::Node]
    attr_accessor :uri

    # The text of the URI being imported after any interpolated SassScript has
    # been resolved. Only set once {Tree::Visitors::Perform} has been run.
    #
    # @return [String]
    attr_accessor :resolved_uri

    # The supports condition for this import.
    #
    # @return [Sass::Supports::Condition]
    attr_accessor :supports_condition

    # The media query for this rule, interspersed with
    # {Sass::Script::Tree::Node}s representing `#{}`-interpolation. Any adjacent
    # strings will be merged together.
    #
    # @return [Array<String, Sass::Script::Tree::Node>]
    attr_accessor :query

    # The media query for this rule, without any unresolved interpolation.
    # It's only set once {Tree::Visitors::Perform} has been run.
    #
    # @return [Sass::Media::QueryList]
    attr_accessor :resolved_query

    # @param uri [String, Sass::Script::Tree::Node] See \{#uri}
    # @param query [Array<String, Sass::Script::Tree::Node>] See \{#query}
    # @param supports_condition [Sass::Supports::Condition] See \{#supports_condition}
    def initialize(uri, query = [], supports_condition = nil)
      @uri = uri
      @query = query
      @supports_condition = supports_condition
      super('')
    end

    # @param uri [String] See \{#resolved_uri}
    # @return [CssImportNode]
    def self.resolved(uri)
      node = new(uri)
      node.resolved_uri = uri
      node
    end

    # @see DirectiveNode#value
    def value; raise NotImplementedError; end

    # @see DirectiveNode#resolved_value
    def resolved_value
      @resolved_value ||=
        begin
          str = "@import #{resolved_uri}"
          str << " supports(#{supports_condition.to_css})" if supports_condition
          str << " #{resolved_query.to_css}" if resolved_query
          str
        end
    end
  end
end