Files
postcss/lib/raw.coffee
T

25 lines
623 B
CoffeeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Property with trimmed and raw value (with comments and spaces)
class Raw
constructor: (@raw, @trimmed) ->
# Set new trimmed value and mark property as changed
set: (value) ->
if @trimmed != value
@changed = true
@trimmed = value
# Stringify to CSS raw value if trimmed wasn’t changed
stringify: (opts = { }) ->
if not @changed
@raw || ''
else if not @raw
(opts.before || '') + @trimmed + (opts.after || '')
else
(if @raw[0] == ' ' then ' ' else '') +
@trimmed +
(if @raw[-1..-1] == ' ' then ' ' else '')
Raw.empty = new Raw()
module.exports = Raw