mirror of
https://github.com/hanzoai/postcss.git
synced 2026-09-24 17:01:56 +00:00
33 lines
828 B
CoffeeScript
33 lines
828 B
CoffeeScript
MapGenerator = require('./map-generator')
|
|
Declaration = require('./declaration')
|
|
Container = require('./container')
|
|
Comment = require('./comment')
|
|
AtRule = require('./at-rule')
|
|
Rule = require('./rule')
|
|
|
|
# Root of CSS
|
|
class Root extends Container.WithRules
|
|
constructor: ->
|
|
@type = 'root'
|
|
@rules = []
|
|
super
|
|
|
|
# Fix spaces on insert before first rule
|
|
normalize: (child, sample, type) ->
|
|
child = super
|
|
if type == 'prepend'
|
|
sample.before = if @rules.length > 1 then @rules[1].before else @after
|
|
child
|
|
|
|
# Stringify styles
|
|
stringify: (builder) ->
|
|
@stringifyContent(builder)
|
|
builder(@after) if @after
|
|
|
|
# Generate processing result with optional source map
|
|
toResult: (opts = { }) ->
|
|
map = new MapGenerator(@, opts)
|
|
map.getResult()
|
|
|
|
module.exports = Root
|