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: 使用innerHTML赋值后转小程序时,a标签转view标签+img转image标签时,把width和height写入style属性 #16780

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

zhengyanan1
Copy link
Contributor

@zhengyanan1 zhengyanan1 commented Nov 1, 2024

这个 PR 做了什么? (简要描述所做更改)

  1. 对于innerHTML生成的小程序, a标签(innerHTML)的转换逻辑保持跟直接a标签一致
  2. 对于innerHTML生成的小程序, img=>image时,如果有width和height,把这2个值写入style属性内的最前部分

这个 PR 是什么类型? (至少选择一个)

  • 错误修复(Bugfix) issue: fix #
  • 新功能(Feature)
  • 代码重构(Refactor)
  • TypeScript 类型定义修改(Typings)
  • 文档修改(Docs)
  • 代码风格更新(Code style update)
  • 其他,请描述(Other, please describe):

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

Attention: Patch coverage is 23.07692% with 30 lines in your changes missing coverage. Please review.

Project coverage is 56.45%. Comparing base (fad526a) to head (b1b4127).
Report is 2 commits behind head on 3.x.

Files with missing lines Patch % Lines
...taro-runtime/src/dom-external/inner-html/parser.ts 13.79% 25 Missing ⚠️
...s/taro-runtime/src/dom-external/inner-html/tags.ts 50.00% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              3.x   #16780      +/-   ##
==========================================
- Coverage   56.51%   56.45%   -0.07%     
==========================================
  Files         500      500              
  Lines       22765    22799      +34     
  Branches     5652     5644       -8     
==========================================
+ Hits        12866    12871       +5     
- Misses       8693     8718      +25     
- Partials     1206     1210       +4     
Flag Coverage Δ
taro-cli 75.00% <ø> (+25.78%) ⬆️
taro-runner 54.01% <ø> (ø)
taro-runtime 76.08% <23.07%> (-3.32%) ⬇️
taro-web 40.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...s/taro-runtime/src/dom-external/inner-html/tags.ts 77.27% <50.00%> (-22.73%) ⬇️
...taro-runtime/src/dom-external/inner-html/parser.ts 68.63% <13.79%> (-11.09%) ⬇️

... and 3 files with indirect coverage changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a 标签是行内元素啊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a标签在H5下是行内元素。
但在转小程序时,会根据参数的差异,转view 或者navigator(直接用a标签的时候)。

如果是innerHTML里用a标签的话,就直接转的text之前。如果a里套了image,就展示不出来了。
这里就是把innerHTML里a标签的转换逻辑,跟直接用a标签基本对齐

@zhengyanan1 zhengyanan1 force-pushed the fix-innerHTML-v3.6.25-harden branch from fc6d97a to b1b4127 Compare November 13, 2024 06:28
@zhengyanan1
Copy link
Contributor Author

fix: 修复innerHTML生成小程序时的相关逻辑。

  1. a标签(innerHTML)的转换逻辑保持跟直接a标签一致
  2. img=>image时,如果有width和height,把这2个值写入style属性内的最前部分

@zhengyanan1 zhengyanan1 merged commit 2965abf into 3.x Nov 13, 2024
21 of 22 checks passed
@zhengyanan1 zhengyanan1 deleted the fix-innerHTML-v3.6.25-harden branch November 13, 2024 07:56
This was referenced Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants