refactor: use parseXml instead of direct call to DOMParser#991
Conversation
Use the existing function to remove duplication and make the code easier to read.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughReplaces direct DOMParser usage with a centralized Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/core/src/util/MaxXmlRequest.ts:
- Line 20: The import in MaxXmlRequest.ts is missing the .js extension; update
the import of parseXml from './xmlUtils' to include the file extension (i.e.,
'./xmlUtils.js') so it satisfies the n/file-extension-in-import ESLint rule and
keeps the parseXml import correct.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/core/src/util/MaxXmlRequest.tspackages/core/src/view/canvas/SvgCanvas2D.ts
🧰 Additional context used
📓 Path-based instructions (6)
packages/core/src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/core/src/**/*.ts: Include.jsfile extensions in all import statements within packages/core/src/ to comply with ESLint rulen/file-extension-in-import.
Do not use console statements in any code. Use proper logging mechanisms instead (ESLint rule:no-console: error).
Do not useeval()function in any code (ESLint rule:no-eval: error).
Do not use const enums. Convert all const enums to regular enums (ESLint rule forbids const enums).
TypeScript source files in core package must strictly maintain typing with no implicit types and all functions having explicit return type annotations.Use singular form for folder names (e.g.,
handler/nothandlers/) and kebab-case for folder names (e.g.,my-feature/notmyFeature/ormy_feature/)
Files:
packages/core/src/util/MaxXmlRequest.tspackages/core/src/view/canvas/SvgCanvas2D.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use single quotes in TypeScript/JavaScript code (Prettier config:
singleQuote: true).
Files:
packages/core/src/util/MaxXmlRequest.tspackages/core/src/view/canvas/SvgCanvas2D.ts
**/*.{ts,tsx,js,jsx,json,md}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Format code using Prettier with tab width 2, trailing comma ES5, print width 90, and end of line auto.
Files:
packages/core/src/util/MaxXmlRequest.tspackages/core/src/view/canvas/SvgCanvas2D.ts
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.ts: Use theisNullish()function when checking fornullorundefinedon variables that can have falsy values (numbers, strings, booleans) to avoid bugs where0,"", orfalseare incorrectly treated as nullish
Use thelog()function frominternal/utils.jsinstead of accessingGlobalConfig.loggerdirectly for logging
Use functionstranslate()andisI18nEnabled()frominternal/i18n-utils.jsinstead of accessingGlobalConfig.i18ndirectly for internationalization
Always wrap multiple model changes inbatchUpdate()to ensure efficient graph updates
Files:
packages/core/src/util/MaxXmlRequest.tspackages/core/src/view/canvas/SvgCanvas2D.ts
**/*.{ts,js}
📄 CodeRabbit inference engine (CLAUDE.md)
Prefer using
BaseGraphin production with explicit feature registration for optimal tree-shaking and minimal bundle size; useGraphonly for prototyping and demos with automatic defaults
Files:
packages/core/src/util/MaxXmlRequest.tspackages/core/src/view/canvas/SvgCanvas2D.ts
packages/core/src/**
📄 CodeRabbit inference engine (CLAUDE.md)
Organize code using the mixin pattern where each mixin provides a specific capability with two files: implementation (.ts) and type definitions (.type.ts), with unified type definitions in
_graph-mixins-types.ts
Files:
packages/core/src/util/MaxXmlRequest.tspackages/core/src/view/canvas/SvgCanvas2D.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 857
File: packages/core/src/view/plugins/SelectionHandler.ts:1081-1092
Timestamp: 2025-06-26T13:27:19.012Z
Learning: User tbouffard prefers to keep PRs focused on their main objective and defer implementation improvements or logic fixes to future dedicated PRs. For maxGraph, refactoring PRs like Dictionary→Map migration should not include unrelated logic improvements even when valid issues are identified in the migrated code.
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
⏰ 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: build
- GitHub Check: build (ubuntu-24.04)
- GitHub Check: build (windows-2022)
🔇 Additional comments (5)
packages/core/src/util/MaxXmlRequest.ts (1)
217-217: LGTM! Successful refactoring to centralized XML parsing.The change from direct
DOMParserusage to theparseXmlutility function achieves the PR objective of removing duplication and improving code readability.packages/core/src/view/canvas/SvgCanvas2D.ts (4)
34-34: LGTM! Import statement correctly includes.jsextension.The import properly extends the existing
xmlUtilsimport to includeparseXmland follows the coding guideline requiring.jsfile extensions.
61-80: LGTM! Documentation examples modernized and aligned with current conventions.The JSDoc example updates improve code quality by:
- Referencing current module naming (
xmlUtils,constants)- Modernizing variable declarations (
constinstead ofvar)- Simplifying conditional checks
These documentation improvements complement the core refactoring objective.
1090-1090: LGTM! HTML parsing centralized throughparseXmlutility.The refactoring successfully replaces direct
DOMParserusage with the centralizedparseXmlfunction, achieving the PR objective for theconvertHtmlmethod.
1150-1150: LGTM! XML parsing centralized throughparseXmlutility.The refactoring successfully replaces direct
DOMParserusage with the centralizedparseXmlfunction, achieving the PR objective for thecreateDivmethod.
|
Converted to draft, the changes introduce a circular dependency between xmlUtils and MaxXmlRequest. This is due to the getViewXml function, but it is not a function manipulating generic XML content, but is generating XML with Codec. It is also only used in the Editor class, so it should be moved first to another file. |
|



Use the existing function to remove duplication and make the code easier to read.
Summary by CodeRabbit
Refactor
Documentation
Style
✏️ Tip: You can customize this high-level summary in your review settings.