Methods

Class Index [+]

Quicksearch

Sass::Selector::Element

An element selector (e.g. `h1`).

Attributes

name[R]

The element name.

@return [Array]

namespace[R]

The selector namespace. `nil` means the default namespace, `[“”]` means no namespace, `[“*”]` means any namespace.

@return [Array, nil]

Public Class Methods

new(name, namespace) click to toggle source

@param name [Array] The element name @param namespace [Array, nil] See {#namespace}

     # File lib/sass/selector.rb, line 163
163:       def initialize(name, namespace)
164:         @name = name
165:         @namespace = namespace
166:       end

Public Instance Methods

to_a() click to toggle source

@see Selector#to_a

     # File lib/sass/selector.rb, line 169
169:       def to_a
170:         @namespace ? @namespace + ["|"] + @name : @name
171:       end
unify(sels) click to toggle source

Unification of an element selector is somewhat complicated, especially when a namespace is specified. First, if `sel` contains another {Element} with a different {#name}, then the selectors can’t be unified and `nil` is returned.

Otherwise, if `sel` doesn’t specify a namespace, or it specifies any namespace (via `”*”`), then it’s returned with this element selector (e.g. `.foo` becomes `a.foo` or `svg|a.foo`). Similarly, if this selector doesn’t specify a namespace, the namespace from `sel` is used.

If both this selector and `sel` specify namespaces, those namespaces are unified via {Simple#unify_namespaces} and the unified namespace is used, if possible.

@todo There are lots of cases that this documentation specifies;

  make sure we thoroughly test **all of them**.

@todo Keep track of whether a default namespace has been declared

  and handle namespace-unspecified selectors accordingly.

@see Selector#unify

     # File lib/sass/selector.rb, line 195
195:       def unify(sels)
196:         case sels.first
197:         when Universal;
198:         when Element; return unless name == sels.first.name
199:         else return [self] + sels
200:         end
201: 
202:         ns, accept = unify_namespaces(namespace, sels.first.namespace)
203:         return unless accept
204:         [Element.new(name, ns)] + sels[1..1]
205:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.