GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: use parseXml instead of direct call to DOMParser by tbouffard · Pull Request #991 · maxGraph/maxGraph

Conversation

@tbouffard

@tbouffard tbouffard commented Jan 7, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Use the existing function to remove duplication and make the code easier to read.

Summary by CodeRabbit

  • Refactor

    • Consolidated XML parsing to a centralized utility across internal rendering paths for more consistent document handling.
  • Documentation

    • Updated docs and examples to reference current utilities and API terminology.
  • Style

    • Simplified conditional checks and modernized variable declarations for clearer, more maintainable code.

✏️ Tip: You can customize this high-level summary in your review settings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tbouffard
refactor: use parseXml instead of direct call to DOMParser
07ac543
Use the existing function to remove duplication and make the code easier to read.
@tbouffard tbouffard added the refactor Code refactoring label Jan 7, 2026
@coderabbitai

coderabbitai Bot commented Jan 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Replaces direct DOMParser usage with a centralized xmlUtils.parseXml call in XML/HTML parsing paths and updates related imports and minor docs/syntax in two files. No public APIs or method signatures changed.

Changes

Cohort / File(s) Summary
XML parsing updates
packages/core/src/util/MaxXmlRequest.ts, packages/core/src/view/canvas/SvgCanvas2D.ts
Replaced inline DOMParser().parseFromString usage with xmlUtils.parseXml(...). SvgCanvas2D imports extended to include parseXml; parsing code paths (e.g., convertHtml, createDiv) updated to use parseXml and access documentElement.
Docs & minor syntax
packages/core/src/view/canvas/SvgCanvas2D.ts
JSDoc references updated from mxUtils/mxConstants to xmlUtils/constants; some var → const modernizations and simplified conditional checks (e.g., == null → !). No public API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is very brief and lacks required template sections including issue reference, scope confirmation, testing details, documentation changes, and conventional commits compliance. Add required sections: issue number reference (closes #xxx), scope confirmation, test details, documentation notes, and verify the title follows Conventional Commits format.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main refactoring change: replacing direct DOMParser calls with the centralized parseXml utility function across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]
coderabbitai Bot reviewed Jan 7, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 42384ac and 07ac543.

📒 Files selected for processing (2)
  • packages/core/src/util/MaxXmlRequest.ts
  • packages/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 .js file extensions in all import statements within packages/core/src/ to comply with ESLint rule n/file-extension-in-import.
Do not use console statements in any code. Use proper logging mechanisms instead (ESLint rule: no-console: error).
Do not use eval() 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/ not handlers/) and kebab-case for folder names (e.g., my-feature/ not myFeature/ or my_feature/)

Files:

  • packages/core/src/util/MaxXmlRequest.ts
  • packages/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.ts
  • packages/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.ts
  • packages/core/src/view/canvas/SvgCanvas2D.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: Use the isNullish() function when checking for null or undefined on variables that can have falsy values (numbers, strings, booleans) to avoid bugs where 0, "", or false are incorrectly treated as nullish
Use the log() function from internal/utils.js instead of accessing GlobalConfig.logger directly for logging
Use functions translate() and isI18nEnabled() from internal/i18n-utils.js instead of accessing GlobalConfig.i18n directly for internationalization
Always wrap multiple model changes in batchUpdate() to ensure efficient graph updates

Files:

  • packages/core/src/util/MaxXmlRequest.ts
  • packages/core/src/view/canvas/SvgCanvas2D.ts
**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

Prefer using BaseGraph in production with explicit feature registration for optimal tree-shaking and minimal bundle size; use Graph only for prototyping and demos with automatic defaults

Files:

  • packages/core/src/util/MaxXmlRequest.ts
  • packages/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.ts
  • packages/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 DOMParser usage to the parseXml utility 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 .js extension.

The import properly extends the existing xmlUtils import to include parseXml and follows the coding guideline requiring .js file 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 (const instead of var)
  • Simplifying conditional checks

These documentation improvements complement the core refactoring objective.


1090-1090: LGTM! HTML parsing centralized through parseXml utility.

The refactoring successfully replaces direct DOMParser usage with the centralized parseXml function, achieving the PR objective for the convertHtml method.


1150-1150: LGTM! XML parsing centralized through parseXml utility.

The refactoring successfully replaces direct DOMParser usage with the centralized parseXml function, achieving the PR objective for the createDiv method.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/util/MaxXmlRequest.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

tbouffard added 2 commits January 7, 2026 16:10
@tbouffard
fix lint errors
a532419
@tbouffard
EXTRA WIP move getViewXml out of xmlUtils (non related function, only…
2609a8f
… used in Editor)
@tbouffard

tbouffard commented Jan 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.
See #992

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tbouffard
tbouffard marked this pull request as draft January 7, 2026 15:35
tbouffard added 4 commits January 7, 2026 16:44
@tbouffard
EXTRA WIP move getViewXml to xmlViewUtils (this is a BREAKING CHANGE)
44c446d
@tbouffard
Revert "EXTRA WIP move getViewXml to xmlViewUtils (this is a BREAKING…
79c8a9b
… CHANGE)"

This reverts commit 44c446d.
@tbouffard
Revert "EXTRA WIP move getViewXml out of xmlUtils (non related functi…
e529ad8
…on, only used in Editor)"

This reverts commit 2609a8f.
@tbouffard
Merge branch 'main' into refactor/use_xmlutils_parseString
ce79773
@sonarqubecloud

sonarqubecloud Bot commented Jan 9, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tbouffard
tbouffard marked this pull request as ready for review January 9, 2026 10:09
@tbouffard
tbouffard merged commit 2f4bb07 into main Jan 9, 2026
@tbouffard
tbouffard deleted the refactor/use_xmlutils_parseString branch January 9, 2026 10:10
@coderabbitai coderabbitai Bot mentioned this pull request Feb 5, 2026
refactor: improve type guard for domUtils.isNode #1000
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Feb 25, 2026
fix: parse HTML instead of XML in SvgCanvas2D.convertHtml #1012
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

refactor Code refactoring

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@tbouffard
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.