-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(issue:3766) add support for container queries (#3811)
* fix(issue:3766) add support for container queries * Add support for CSS Container Queries * Add tests for CSS Container Queries * feat(media-queries-level-4) update media query * Add support for Media Queries Level 4. * Add tests for Media Queries Level 4. * fix(mq-4 regex) fix regex for media queries * Fix regex used for Media Queries Level 4 syntax parsing. * fix(media-query-syntax) fix parsing of invalid CSS * Fix parsing of invalid CSS for media queries to be consistent with Less.js version 4.1.3 handling.
- Loading branch information
Showing
18 changed files
with
14,977 additions
and
14,066 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const MediaSyntaxOptions = { | ||
queryInParens: true | ||
}; | ||
|
||
export const ContainerSyntaxOptions = { | ||
queryInParens: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Ruleset from './ruleset'; | ||
import Value from './value'; | ||
import Selector from './selector'; | ||
import AtRule from './atrule'; | ||
import NestableAtRulePrototype from './nested-at-rule'; | ||
|
||
const Container = function(value, features, index, currentFileInfo, visibilityInfo) { | ||
this._index = index; | ||
this._fileInfo = currentFileInfo; | ||
|
||
const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors(); | ||
|
||
this.features = new Value(features); | ||
this.rules = [new Ruleset(selectors, value)]; | ||
this.rules[0].allowImports = true; | ||
this.copyVisibilityInfo(visibilityInfo); | ||
this.allowRoot = true; | ||
this.setParent(selectors, this); | ||
this.setParent(this.features, this); | ||
this.setParent(this.rules, this); | ||
}; | ||
|
||
Container.prototype = Object.assign(new AtRule(), { | ||
type: 'Container', | ||
|
||
...NestableAtRulePrototype, | ||
|
||
genCSS(context, output) { | ||
output.add('@container ', this._fileInfo, this._index); | ||
this.features.genCSS(context, output); | ||
this.outputRuleset(context, output, this.rules); | ||
}, | ||
|
||
eval(context) { | ||
if (!context.mediaBlocks) { | ||
context.mediaBlocks = []; | ||
context.mediaPath = []; | ||
} | ||
|
||
const media = new Container(null, [], this._index, this._fileInfo, this.visibilityInfo()); | ||
if (this.debugInfo) { | ||
this.rules[0].debugInfo = this.debugInfo; | ||
media.debugInfo = this.debugInfo; | ||
} | ||
|
||
media.features = this.features.eval(context); | ||
|
||
context.mediaPath.push(media); | ||
context.mediaBlocks.push(media); | ||
|
||
this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); | ||
context.frames.unshift(this.rules[0]); | ||
media.rules = [this.rules[0].eval(context)]; | ||
context.frames.shift(); | ||
|
||
context.mediaPath.pop(); | ||
|
||
return context.mediaPath.length === 0 ? media.evalTop(context) : | ||
media.evalNested(context); | ||
} | ||
}); | ||
|
||
export default Container; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.