Skip to content

Commit

Permalink
Fix stretch support
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Mar 23, 2020
1 parent d3e5058 commit a38e426
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
11 changes: 9 additions & 2 deletions data/prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,20 @@ f(intrinsic, browsers =>
})
)

f(intrinsic, { match: /x|\s#4/ }, browsers =>
f(intrinsic, { match: /x|\s#4/ }, browsers => {
browsers = browsers.map(i => {
if (/safari/.test(i)) {
return i
} else {
return `${ i } old`
}
})
prefix(['fill', 'fill-available', 'stretch'], {
props: sizeProps,
feature: 'intrinsic-width',
browsers
})
)
})

f(intrinsic, { match: /x|\s#5/ }, browsers =>
prefix(['fit-content'], {
Expand Down
16 changes: 10 additions & 6 deletions lib/hacks/intrinsic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@ class Intrinsic extends Value {
}

replace (string, prefix) {
if (prefix === '-moz-' && this.isStretch()) {
if (prefix === '-moz- old' && this.isStretch()) {
return string.replace(this.regexp(), '$1-moz-available$3')
}
if (prefix === '-webkit-' && this.isStretch()) {
} else if (prefix === '-webkit- old' && this.isStretch()) {
return string.replace(this.regexp(), '$1-webkit-fill-available$3')
} else if (prefix === '-webkit-' && this.isStretch()) {
return string.replace(this.regexp(), '$1-webkit-stretch$3')
} else {
return super.replace(string, prefix)
}
return super.replace(string, prefix)
}

old (prefix) {
let prefixed = prefix + this.name
if (this.isStretch()) {
if (prefix === '-moz-') {
if (prefix === '-moz- old') {
prefixed = '-moz-available'
} else if (prefix === '-webkit-') {
} else if (prefix === '-webkit- old') {
prefixed = '-webkit-fill-available'
} else if (prefix === '-webkit-') {
prefixed = '-webkit-stretch'
}
}
return new OldValue(this.name, prefixed, prefixed, regexp(prefixed))
Expand Down
3 changes: 3 additions & 0 deletions test/cases/intrinsic.out.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
a {
width: -webkit-fill-available;
width: -webkit-stretch;
width: -moz-available;
width: stretch;
}
Expand All @@ -21,12 +22,14 @@ p {

.outdated {
width: -webkit-fill-available;
width: -webkit-stretch;
width: -moz-available;
width: fill;
}

.old {
width: -webkit-fill-available;
width: -webkit-stretch;
width: -moz-available;
width: fill-available;
}
Expand Down

0 comments on commit a38e426

Please sign in to comment.