Skip to content

Commit

Permalink
Implement selector contextualization for keyframe rules
Browse files Browse the repository at this point in the history
Fixes sass#947
  • Loading branch information
mgreter committed Mar 28, 2015
1 parent 091010d commit 8650a3b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ namespace Sass {
// Keyframe-rules -- the child blocks of "@keyframes" nodes.
///////////////////////////////////////////////////////////////////////
class Keyframe_Rule : public Has_Block {
ADD_PROPERTY(String*, rules);
ADD_PROPERTY(Selector*, selector);
public:
Keyframe_Rule(ParserState pstate, Block* b)
: Has_Block(pstate, b), rules_(0)
: Has_Block(pstate, b), selector_(0)
{ statement_type(KEYFRAMERULE); }
ATTACH_OPERATIONS();
};
Expand Down
2 changes: 1 addition & 1 deletion cssize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace Sass {

Keyframe_Rule* rr = new (ctx.mem) Keyframe_Rule(r->pstate(),
r->block()->perform(this)->block());
if (r->rules()) rr->rules(r->rules());
if (r->selector()) rr->selector(r->selector());

return debubble(rr->block(), rr)->block();
}
Expand Down
5 changes: 5 additions & 0 deletions debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
cerr << ind << "Declaration " << block << " " << block->tabs() << endl;
debug_ast(block->property(), ind + " prop: ", env);
debug_ast(block->value(), ind + " value: ", env);
} else if (dynamic_cast<Keyframe_Rule*>(node)) {
Keyframe_Rule* has_block = dynamic_cast<Keyframe_Rule*>(node);
cerr << ind << "Keyframe_Rule " << has_block << " " << has_block->tabs() << endl;
if (has_block->selector()) debug_ast(has_block->selector(), ind + "@");
if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<At_Rule*>(node)) {
At_Rule* block = dynamic_cast<At_Rule*>(node);
cerr << ind << "At_Rule " << block << " [" << block->keyword() << "] " << block->tabs() << endl;
Expand Down
6 changes: 1 addition & 5 deletions expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ namespace Sass {
if (in_keyframes) {
To_String to_string;
Keyframe_Rule* k = new (ctx.mem) Keyframe_Rule(r->pstate(), r->block()->perform(this)->block());
if (r->selector()) {
string s(r->selector()->perform(eval->with(env, backtrace))->perform(&to_string));
String_Constant* ss = new (ctx.mem) String_Constant(r->selector()->pstate(), s);
k->rules(ss);
}
if (r->selector()) k->selector(r->selector()->perform(contextualize->with(0, env, backtrace)));
in_at_root = old_in_at_root;
old_in_at_root = false;
return k;
Expand Down
5 changes: 2 additions & 3 deletions inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ namespace Sass {

void Inspect::operator()(Keyframe_Rule* rule)
{
append_indentation();
if (rule->rules()) rule->rules()->perform(this);
rule->block()->perform(this);
if (rule->selector()) rule->selector()->perform(this);
if (rule->block()) rule->block()->perform(this);
}

void Inspect::operator()(Propset* propset)
Expand Down
3 changes: 1 addition & 2 deletions output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ namespace Sass {

void Output::operator()(Keyframe_Rule* r)
{
String* v = r->rules();
Block* b = r->block();
Selector* v = r->selector();

if (v) {
append_indentation();
v->perform(this);
}

Expand Down

0 comments on commit 8650a3b

Please sign in to comment.