Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add crutch to help browsers interpreting sourcemaps #1759

Merged
merged 1 commit into from
Nov 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Sass {
scheduled_space(0),
scheduled_linefeed(0),
scheduled_delimiter(false),
scheduled_mapping(0),
in_comment(false),
in_wrapped(false),
in_media_block(false),
Expand Down Expand Up @@ -44,6 +45,8 @@ namespace Sass {
void Emitter::set_filename(const std::string& str)
{ wbuf.smap.file = str; }

void Emitter::schedule_mapping(AST_Node* node)
{ scheduled_mapping = node; }
void Emitter::add_open_mapping(AST_Node* node)
{ wbuf.smap.add_open_mapping(node); }
void Emitter::add_close_mapping(AST_Node* node)
Expand Down Expand Up @@ -137,6 +140,12 @@ namespace Sass {
{
flush_schedules();
add_open_mapping(node);
// hotfix for browser issues
// this is pretty ugly indeed
if (scheduled_mapping) {
add_open_mapping(scheduled_mapping);
scheduled_mapping = 0;
}
append_string(text);
add_close_mapping(node);
}
Expand Down
2 changes: 2 additions & 0 deletions src/emitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Sass {
void set_filename(const std::string& str);
void add_open_mapping(AST_Node* node);
void add_close_mapping(AST_Node* node);
void schedule_mapping(AST_Node* node);
std::string render_srcmap(Context &ctx);
ParserState remap(const ParserState& pstate);

Expand All @@ -35,6 +36,7 @@ namespace Sass {
size_t scheduled_space;
size_t scheduled_linefeed;
bool scheduled_delimiter;
AST_Node* scheduled_mapping;

public:
// output strings different in comments
Expand Down
3 changes: 3 additions & 0 deletions src/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,10 @@ namespace Sass {
for (size_t i = 0, L = g->length(); i < L; ++i) {
if (!in_wrapped && i == 0) append_indentation();
if ((*g)[i] == 0) continue;
schedule_mapping((*g)[i]->last());
// add_open_mapping((*g)[i]->last());
(*g)[i]->perform(this);
// add_close_mapping((*g)[i]->last());
if (i < L - 1) {
scheduled_space = 0;
append_comma_separator();
Expand Down