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

Fix #954 #955

Merged
merged 9 commits into from
Dec 13, 2017
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
11 changes: 9 additions & 2 deletions lib/hacks/grid-template-areas.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,22 @@ class GridTemplateAreas extends Declaration {

static names = ['grid-template-areas'];

getRoot(parent) {
if (parent.type === 'atrule' || parent.type === 'root') {
return parent;
}
return this.getRoot(parent.parent);
}

/**
* Translate grid-template-areas to separate -ms- prefixed properties
*/
insert(decl, prefix, prefixes, result) {
if (prefix !== '-ms-') return super.insert(decl, prefix, prefixes);

const areas = parseGridAreas(decl.value);
decl.root().walkDecls('grid-area', gridArea => {
const root = this.getRoot(decl.parent);
root.walkDecls('grid-area', gridArea => {
const value = gridArea.value;
const area = areas[value];
delete areas[value];
Expand Down Expand Up @@ -92,7 +100,6 @@ class GridTemplateAreas extends Declaration {

return decl;
}

}

module.exports = GridTemplateAreas;
14 changes: 14 additions & 0 deletions test/cases/grid-template-areas.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,17 @@
.e {
grid-area: foot;
}

@media (max-width: 1000px) {
.a {
grid-template-areas: "head main";
}

.b {
grid-area: head;
}

.c {
grid-area: main;
}
}
18 changes: 18 additions & 0 deletions test/cases/grid-template-areas.out.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,21 @@
-ms-grid-column: 2;
grid-area: foot;
}

@media (max-width: 1000px) {
.a {
grid-template-areas: "head main";
}

.a {
-ms-grid-row: 1;
-ms-grid-column: 1;
grid-area: head;
}

.b {
-ms-grid-row: 1;
-ms-grid-column: 2;
grid-area: main;
}
}