-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
fix(runtime-dom): export nodeOps and patchProp for easier custom render creation #13753
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
Conversation
WalkthroughAdds named re-exports for nodeOps and patchProp from runtime-dom’s index.ts, expanding the module’s public API. No runtime behavior or control flow changes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai
coderabbitai
bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/runtime-dom/src/index.ts (1)
20-20
: Document and track the new public exportsThis expands the public API. Please:
- Add an API/docs note that nodeOps and patchProp are available from @vue/runtime-dom for custom renderers.
- Add a changelog entry (semver: minor).
- Double-check d.ts output to ensure consumers without "dom" lib in tsconfig don’t hit surprising type errors. Given this is runtime-dom, it should be fine.
I can draft the changelog and a short docs blurb if helpful.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/runtime-dom/src/index.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
🔇 Additional comments (1)
packages/runtime-dom/src/index.ts (1)
20-20
: Public API addition for custom renderers — LGTMRe-exporting nodeOps and patchProp from the runtime-dom entry is a clean way to enable custom renderer composition without deep imports. No runtime behavior changes; size impact is negligible since both are already imported for rendererOptions.
@coderabbitai where can I add documentation?
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# First, let's explore the repository structure to understand where documentation is typically placed
echo "=== Repository structure overview ==="
ls -la
echo -e "\n=== Looking for documentation directories ==="
fd -t d -I "doc" --max-depth 3
fd -t d -I "docs" --max-depth 3
echo -e "\n=== Looking for README files ==="
fd "README" --max-depth 2
echo -e "\n=== Checking packages structure ==="
ls -la packages/
echo -e "\n=== Looking at runtime-dom package structure ==="
ls -la packages/runtime-dom/
echo -e "\n=== Checking for existing documentation in runtime-dom ==="
fd -t f "README" packages/runtime-dom/
fd -t f "*.md" packages/runtime-dom/
Length of output: 4773
🏁 Script executed:
#!/bin/bash
# Let's check the existing runtime-dom README to see how it documents exports
echo "=== Current runtime-dom README content ==="
cat packages/runtime-dom/README.md
echo -e "\n=== Let's also check the main Vue README for documentation patterns ==="
head -50 README.md
echo -e "\n=== Check for any TypeScript declaration files that might contain documentation ==="
fd --glob "*.d.ts" packages/runtime-dom/
echo -e "\n=== Look at the actual index.ts file to see current exports and any existing documentation ==="
cat packages/runtime-dom/src/index.ts
echo -e "\n=== Check if there are JSDoc comments in nodeOps and patchProp files ==="
head -20 packages/runtime-dom/src/nodeOps.ts
echo "..."
head -20 packages/runtime-dom/src/patchProp.ts
Length of output: 13434
🏁 Script executed:
#!/bin/bash
# Let's check if there's a contributing guide that mentions documentation practices
echo "=== Looking for contributing guidelines ==="
fd "CONTRIBUTING" --max-depth 2
# Check the .github directory for any documentation guidelines
echo -e "\n=== Checking .github directory ==="
ls -la .github/
# Let's see if there are any existing JSDoc comments for similar exports in the codebase
echo -e "\n=== Looking for JSDoc patterns in similar exports ==="
rg -A 5 -B 2 "export.*{.*}" packages/runtime-dom/src/index.ts
# Check if there are any official Vue.js documentation repositories or links
echo -e "\n=== Looking for any documentation-related files ==="
rg -i "documentation|docs" README.md
# Let's also check what nodeOps and patchProp actually are
echo -e "\n=== Full nodeOps file to understand what it exports ==="
tail -50 packages/runtime-dom/src/nodeOps.ts
echo -e "\n=== Full patchProp file to understand what it exports ==="
tail -50 packages/runtime-dom/src/patchProp.ts
Length of output: 4871
🏁 Script executed:
#!/bin/bash
# Let's check the contributing guide to see if it mentions documentation practices
echo "=== Checking contributing guide for documentation practices ==="
cat .github/contributing.md
# Also check if there are any existing JSDoc comments in the codebase for reference
echo -e "\n=== Looking for JSDoc examples in runtime-dom ==="
rg -B 2 -A 2 "/\*\*" packages/runtime-dom/src/ --type ts
# Let's see the complete nodeOps and patchProp exports to understand their structure
echo -e "\n=== Complete nodeOps export structure ==="
rg -A 200 "export.*nodeOps" packages/runtime-dom/src/nodeOps.ts
echo -e "\n=== Complete patchProp export structure ==="
rg -A 50 "export.*patchProp" packages/runtime-dom/src/patchProp.ts
Length of output: 49742
@stefanonepanedap Based on my analysis of the Vue.js core repository, here are the recommended places where you can add documentation for the newly exported nodeOps
and patchProp
:
1. JSDoc Comments in index.ts (Recommended)
Add JSDoc comments directly above the export statement in packages/runtime-dom/src/index.ts
:
/** * Platform-agnostic node operations for DOM manipulation. * Used internally by Vue's DOM renderer and can be used for creating custom renderers. * * @example * ```js * import { nodeOps, patchProp, createRenderer } from '@vue/runtime-dom' * * const customRenderer = createRenderer({ * ...nodeOps, * patchProp * }) * ``` */ export { nodeOps } from './nodeOps' /** * Platform-specific property patching function for DOM elements. * Handles class, style, events, and other DOM properties/attributes. * Used internally by Vue's DOM renderer and can be used for creating custom renderers. * * @param el - The target DOM element * @param key - The property/attribute key * @param prevValue - Previous value * @param nextValue - New value * @param namespace - Element namespace (svg, mathml, etc.) * @param parentComponent - Parent component instance (for context) */ export { patchProp } from './patchProp'
2. Update the runtime-dom README.md
Enhance packages/runtime-dom/README.md
with examples showing how to use the newly exported functions:
# @vue/runtime-dom ```js import { h, createApp } from '@vue/runtime-dom' const RootComponent = { render() { return h('div', 'hello world') }, } createApp(RootComponent).mount('#app')
Custom Renderer Creation
The nodeOps
and patchProp
exports enable you to create custom renderers:
import { createRenderer, nodeOps, patchProp } from '@vue/runtime-dom' // Create a custom renderer using DOM operations const customRenderer = createRenderer({ ...nodeOps, patchProp, // Add custom logic here })
## 3. Inline Documentation in Source Files (Optional)
You could also add more detailed JSDoc comments in the source files themselves (`nodeOps.ts` and `patchProp.ts`), but since these are already well-structured, the export-level documentation would be sufficient.
## Best Practices
Based on the existing codebase patterns:
- Use standard JSDoc format with `/**` comments
- Include `@example` blocks showing practical usage
- Keep examples focused on the custom renderer use case (the main reason for exporting these)
- Follow the existing documentation style seen in other parts of the codebase
The JSDoc approach is most appropriate since it will appear in IDE intellisense and generated type documentation, making it immediately helpful to developers using these exports.
Uh oh!
There was an error while loading. Please reload this page.
This PR exposes nodeOps and patchProps in order to facilitate the extension of web base custom renderers.
eg. Implementing scopedRegistry for custom component support.
Summary by CodeRabbit