Skip to content

Commit efd97da

Browse files
committed
Add support for custom property syntax
1 parent 57c5da5 commit efd97da

15 files changed

+168
-10
lines changed

src/ast.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,6 +2394,13 @@ namespace Sass {
23942394
return quote(value_, '*');
23952395
}
23962396

2397+
bool Declaration::is_invisible() const
2398+
{
2399+
if (is_custom_property()) return false;
2400+
2401+
return !(value_ && value_->concrete_type() != Expression::NULL_VAL);
2402+
}
2403+
23972404
//////////////////////////////////////////////////////////////////////////////////////////
23982405
// Additional method on Lists to retrieve values directly or from an encompassed Argument.
23992406
//////////////////////////////////////////////////////////////////////////////////////////

src/ast.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,19 +660,22 @@ namespace Sass {
660660
ADD_PROPERTY(String_Obj, property)
661661
ADD_PROPERTY(Expression_Obj, value)
662662
ADD_PROPERTY(bool, is_important)
663+
ADD_PROPERTY(bool, is_custom_property)
663664
ADD_PROPERTY(bool, is_indented)
664665
public:
665666
Declaration(ParserState pstate,
666-
String_Obj prop, Expression_Obj val, bool i = false, Block_Obj b = 0)
667-
: Has_Block(pstate, b), property_(prop), value_(val), is_important_(i), is_indented_(false)
667+
String_Obj prop, Expression_Obj val, bool i = false, bool c = false, Block_Obj b = 0)
668+
: Has_Block(pstate, b), property_(prop), value_(val), is_important_(i), is_custom_property_(c), is_indented_(false)
668669
{ statement_type(DECLARATION); }
669670
Declaration(const Declaration* ptr)
670671
: Has_Block(ptr),
671672
property_(ptr->property_),
672673
value_(ptr->value_),
673674
is_important_(ptr->is_important_),
675+
is_custom_property_(ptr->is_custom_property_),
674676
is_indented_(ptr->is_indented_)
675677
{ statement_type(DECLARATION); }
678+
virtual bool is_invisible() const;
676679
ATTACH_AST_OPERATIONS(Declaration)
677680
ATTACH_OPERATIONS()
678681
};

src/constants.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ namespace Sass {
8080
extern const char keyframes_kwd[] = "keyframes";
8181
extern const char only_kwd[] = "only";
8282
extern const char rgb_fn_kwd[] = "rgb(";
83+
extern const char url_fn_kwd[] = "url(";
8384
extern const char url_kwd[] = "url";
8485
// extern const char url_prefix_fn_kwd[] = "url-prefix(";
8586
extern const char important_kwd[] = "important";

src/constants.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ namespace Sass {
8080
extern const char keyframes_kwd[];
8181
extern const char only_kwd[];
8282
extern const char rgb_fn_kwd[];
83+
extern const char url_fn_kwd[];
8384
extern const char url_kwd[];
8485
// extern const char url_prefix_fn_kwd[];
8586
extern const char important_kwd[];

src/cssize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ namespace Sass {
5454
d->pstate(),
5555
property,
5656
d->value(),
57-
d->is_important());
57+
d->is_important(),
58+
d->is_custom_property());
5859
dd->is_indented(d->is_indented());
5960
dd->tabs(d->tabs());
6061

src/debugger.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
415415
Declaration_Ptr block = Cast<Declaration>(node);
416416
std::cerr << ind << "Declaration " << block;
417417
std::cerr << " (" << pstate_source_position(node) << ")";
418+
std::cerr << " [is_custom_property: " << block->is_custom_property() << "] ";
418419
std::cerr << " " << block->tabs() << std::endl;
419420
debug_ast(block->property(), ind + " prop: ", env);
420421
debug_ast(block->value(), ind + " value: ", env);

src/emitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace Sass {
1515
scheduled_linefeed(0),
1616
scheduled_delimiter(false),
1717
scheduled_mapping(0),
18+
in_custom_property(false),
1819
in_comment(false),
1920
in_wrapped(false),
2021
in_media_block(false),
@@ -209,7 +210,7 @@ namespace Sass {
209210
{
210211
scheduled_space = 0;
211212
append_string(":");
212-
append_optional_space();
213+
if (!in_custom_property) append_optional_space();
213214
}
214215

215216
void Emitter::append_mandatory_space()

src/emitter.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ namespace Sass {
4040
AST_Node_Ptr scheduled_mapping;
4141

4242
public:
43+
// output strings different in custom css properties
44+
bool in_custom_property;
4345
// output strings different in comments
4446
bool in_comment;
4547
// selector list does not get linefeeds

src/expand.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ namespace Sass {
265265
new_p,
266266
value,
267267
d->is_important(),
268+
d->is_custom_property(),
268269
bb);
269270
decl->tabs(d->tabs());
270271
return decl;

src/inspect.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ namespace Sass {
123123
if (dec->value()->concrete_type() == Expression::NULL_VAL) return;
124124
bool was_decl = in_declaration;
125125
in_declaration = true;
126+
LOCAL_FLAG(in_custom_property, dec->is_custom_property());
127+
126128
if (output_style() == NESTED)
127129
indentation += dec->tabs();
128130
append_indentation();

0 commit comments

Comments
 (0)