Skip to content

Commit

Permalink
修复了使用 grid 布局时可能样式错误的问题 #413
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-yufeng committed Mar 15, 2022
1 parent 9aaa9bc commit c6032b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/miniprogram/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ Parser.prototype.popNode = function () {
}

// flex 布局时部分样式需要提取到 rich-text 外层
const flex = parent && (parent.attrs.style || '').includes('flex') && !node.c
const flex = parent && ((parent.attrs.style || '').includes('flex') || (parent.attrs.style || '').includes('grid')) && !node.c
// #ifdef MP-WEIXIN || MP-QQ
&& !(styleObj.display || '').includes('inline') // eslint-disable-line
// #endif
Expand Down Expand Up @@ -902,7 +902,7 @@ Parser.prototype.popNode = function () {
for (const key in styleObj) {
if (styleObj[key]) {
const val = `;${key}:${styleObj[key].replace(' !important', '')}`
if (flex && ((key.includes('flex') && key !== 'flex-direction') || key === 'align-self' || styleObj[key][0] === '-' || (key === 'width' && val.includes('%')))) {
if (flex && ((key.includes('flex') && key !== 'flex-direction') || key === 'align-self' || key.includes('grid') || styleObj[key][0] === '-' || (key.includes('width') && val.includes('%')))) {
node.f += val
if (key === 'width') {
attrs.style += ';width:100%'
Expand Down
4 changes: 2 additions & 2 deletions src/uni-app/components/mp-html/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ Parser.prototype.popNode = function () {
}
}
// flex 布局时部分样式需要提取到 rich-text 外层
const flex = parent && (parent.attrs.style || '').includes('flex')
const flex = parent && ((parent.attrs.style || '').includes('flex') || (parent.attrs.style || '').includes('grid'))
// #ifdef MP-WEIXIN
// 检查基础库版本 virtualHost 是否可用
&& !(node.c && wx.getNFCAdapter) // eslint-disable-line
Expand Down Expand Up @@ -995,7 +995,7 @@ Parser.prototype.popNode = function () {
if (styleObj[key]) {
const val = `;${key}:${styleObj[key].replace(' !important', '')}`
/* #ifndef APP-PLUS-NVUE */
if (flex && ((key.includes('flex') && key !== 'flex-direction') || key === 'align-self' || styleObj[key][0] === '-' || (key === 'width' && val.includes('%')))) {
if (flex && ((key.includes('flex') && key !== 'flex-direction') || key === 'align-self' || key.includes('grid') || styleObj[key][0] === '-' || (key.includes('width') && val.includes('%')))) {
node.f += val
if (key === 'width') {
attrs.style += ';width:100%'
Expand Down

0 comments on commit c6032b1

Please sign in to comment.