Skip to content

fix(h5): match video context IDs literally - #19702

Open
Jarvis636431 wants to merge 1 commit into
NervJS:mainfrom
Jarvis636431:codex/h5-video-context-id
Open

Jarvis636431 wants to merge 1 commit into
NervJS:mainfrom
Jarvis636431:codex/h5-video-context-id

Conversation

@Jarvis636431

@Jarvis636431 Jarvis636431 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #19701

这个 PR 做了什么?

createVideoContext 对 clip:1 等合法 ID 拼接不合法 CSS 选择器并抛错。

在现有页面/组件查找范围内按 ID 字面值匹配。5 项回归覆盖标点、空格、普通 ID、同名跨页节点和缺失目标。

这个 PR 是什么类型?

  • 错误修复 (Bugfix)

这个 PR 涉及以下平台:

  • Web 端(H5)

Summary by CodeRabbit

  • Bug 修复
    • 修复视频上下文按 ID 查找的问题,包含空格或特殊字符的 ID 现在也能正确匹配。
    • 查找仅返回当前页面中 ID 完全一致的视频;找不到对应视频时仍返回未定义。

验证结果

H5 全套 52 个套件、590 项测试通过。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T08:21:35.869578Z 0a0a2bb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

createVideoContext 现在遍历当前页面的 taro-video-core 元素,并按 ID 严格相等匹配。新增测试覆盖含特殊字符或空格的 ID、跨页面同名元素,以及不存在的 ID。

Changes

视频上下文查找

Layer / File(s) Summary
字面 ID 查找与回归测试
packages/taro-h5/src/api/media/video/index.ts, packages/taro-h5/__tests__/media/video-context.test.ts
createVideoContext 改为遍历带 ID 的 taro-video-core 元素,并返回第一个 ID 与参数严格相等的元素。测试覆盖特殊字符、空格、跨页面同名元素和缺失目标。

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: zakarycode, single-dancer

Merge Risk: Minimal · up to 0a0a2

createVideoContext now matches video IDs literally, so IDs containing punctuation or spaces no longer throw. Existing page and component scoping is preserved, and regression tests cover the stated cases. No concrete merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(h5): match video context IDs literally”描述了主要变更:H5 中 createVideoContext 改为按字面值匹配视频 ID。变更摘要显示,代码不再把 id 拼入 CSS 选择器,而是遍历带 id 的 taro-video-core 元素并严格比较 id。测试也覆盖特殊字符、空格和不存在的 ID。标题简洁、具体,与变更内容一致。
Linked Issues check Passed [#19701] 要求在现有页面/组件查找范围内按 ID 字面值匹配 createVideoContext,避免 clip:1 等合法 ID 生成非法 CSS 选择器。PR 将 packages/taro-h5/src/api/media/video/index.ts 中的 querySelector(taro-video-core[id=${id}]) 替换为:在 findDOM(inst)…
Out of Scope Changes check Passed 与 whole-PR diff(merge base 033c823 至 head 0a0a2bb)相比,变更仅包括:1)packages/taro-h5/src/api/media/video/index.ts 中 createVideoContext 的单行查找逻辑修改;2)packages/taro-h5/tests/media/video-context.test.ts 中新增的回…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Linked Issues check

Explanation

[#19701] 要求在现有页面/组件查找范围内按 ID 字面值匹配 createVideoContext,避免 clip:1 等合法 ID 生成非法 CSS 选择器。PR 将 packages/taro-h5/src/api/media/video/index.ts 中的 querySelector(taro-video-core[id=${id}]) 替换为:在 findDOM(inst) 返回的元素内执行 querySelectorAll('taro-video-core[id]'),再用 video.id === id 严格比较。该改动不再拼接选择器,因此特殊字符和空格不会抛错。查找范围仍是 findDOM(inst) 的后代元素,与原有范围一致。未找到目标时返回 undefined。PR 摘要称测试 video-context.test.ts 覆盖标点、空格、普通 ID、同名跨页节点和缺失目标 5 项场景;摘要中的测试断言与该实现一致。未检查测试文件源码本身,但实现层面的需求已满足。

Full details: Out of Scope Changes check

Explanation

与 whole-PR diff(merge base 033c823 至 head 0a0a2bb)相比,变更仅包括:1)packages/taro-h5/src/api/media/video/index.ts 中 createVideoContext 的单行查找逻辑修改;2)packages/taro-h5/tests/media/video-context.test.ts 中新增的回归测试。测试文件直接验证该 bug 修复,属于支持性测试,与 #19701 相关。未发现与该 issue 无关的变更。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

小兔捧着测试跑,
冒号引号都匹配。
空格方括号不绕路,
当前页面找到你。
找不到时返回空,
耳朵摇摇收工去。

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8193c74a-f70a-45e8-a93e-9de74e15ada2
Commits

Reviewing files that changed from the base of the PR and between 033c823 and 0a0a2bb.

Files selected for processing: 2

  • packages/taro-h5/__tests__/media/video-context.test.ts
  • packages/taro-h5/src/api/media/video/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.54%. Comparing base (033c823) to head (0a0a2bb).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #19702   +/-   ##
=======================================
  Coverage   59.53%   59.54%           
=======================================
  Files         473      473           
  Lines       26652    26652           
  Branches     6710     6700   -10     
=======================================
+ Hits        15868    15870    +2     
+ Misses       8993     8956   -37     
- Partials     1791     1826   +35     
Flag Coverage Δ
taro-cli 59.69% <ø> (ø)
taro-runtime 66.45% <ø> (ø)
taro-web 75.60% <100.00%> (+0.04%) ⬆️

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

Files with missing lines Coverage Δ
packages/taro-h5/src/api/media/video/index.ts 100.00% <100.00%> (+20.00%) ⬆️

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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.

fix(h5): match video context IDs literally

1 participant