Skip to content

Stringify @host and @custom media #36

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

Closed
wants to merge 2 commits into from
Closed
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
20 changes: 10 additions & 10 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@

* add source map generation

1.3.2 / 2013-10-18
1.3.2 / 2013-10-18
==================

* fix whitespace and indentation in the Compressed compiler.
* add @namespace support
* add .stylesheet(node)

1.3.1 / 2013-06-02
1.3.1 / 2013-06-02
==================

* fix output of rules with no declarations for Identity compiler
* fix defaulting of options

1.3.0 / 2013-05-28
1.3.0 / 2013-05-28
==================

* add ignoring of empty rulesets. Closes #7
Expand All @@ -33,38 +33,38 @@
* fix trailing ; with comments within rules
* fix comment indentation

1.2.0 / 2013-05-21
1.2.0 / 2013-05-21
==================

* add @document compilation. Closes #82

1.1.0 / 2013-03-19
1.1.0 / 2013-03-19
==================

* add omission of comments when compressed
* add comment support

1.0.5 / 2013-03-15
1.0.5 / 2013-03-15
==================

* fix indentation of multiple selectors in @media. Closes #11

1.0.4 / 2012-11-15
1.0.4 / 2012-11-15
==================

* fix indentation

1.0.3 / 2012-09-04
1.0.3 / 2012-09-04
==================

* add __@charset__ support [rstacruz]

1.0.2 / 2012-09-01
1.0.2 / 2012-09-01
==================

* add component support

1.0.1 / 2012-07-26
1.0.1 / 2012-07-26
==================

* add "selectors" array support
Expand Down
19 changes: 19 additions & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ Compiler.prototype['font-face'] = function(node){
+ this.emit('}');
};

/**
* Visit host node.
*/

Compiler.prototype.host = function(node){
return this.emit('@host', node.position, true)
+ this.emit('{')
+ this.mapVisit(node.rules)
+ this.emit('}');
};

/**
* Visit custom-media node.
*/

Compiler.prototype['custom-media'] = function(node){
return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
};

/**
* Visit rule node.
*/
Expand Down
23 changes: 23 additions & 0 deletions lib/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,29 @@ Compiler.prototype['font-face'] = function(node){
+ this.emit('\n}');
};

/**
* Visit host node.
*/

Compiler.prototype.host = function(node){
return this.emit('@host', node.position, true)
+ this.emit(
' {\n'
+ this.indent(1))
+ this.mapVisit(node.rules, '\n\n')
+ this.emit(
this.indent(-1)
+ '\n}');
};

/**
* Visit custom-media node.
*/

Compiler.prototype['custom-media'] = function(node){
return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
};

/**
* Visit rule node.
*/
Expand Down
1 change: 1 addition & 0 deletions test/cases/custom-media.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@custom-media --wide-window screen and (min-width: 40em);
1 change: 1 addition & 0 deletions test/cases/host.compressed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@host{:scope{display:block;}}
5 changes: 5 additions & 0 deletions test/cases/host.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@host {
:scope {
display: block;
}
}