Skip to content

Commit

Permalink
bugfix: #1547 Before calling serializeToString in mmdc_playwright.py,…
Browse files Browse the repository at this point in the history
… make sure the SVG element exists.
  • Loading branch information
voidking committed Nov 1, 2024
1 parent b5bb4d7 commit 0443865
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions metagpt/utils/mmdc_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ async def console_message(msg):
if "svg" in suffixes:
svg_xml = await page.evaluate(
"""() => {
const svg = document.querySelector('svg');
const xmlSerializer = new XMLSerializer();
return xmlSerializer.serializeToString(svg);
}"""
const svg = document.querySelector('svg');
if (!svg) {
throw new Error('SVG element not found');
}
const xmlSerializer = new XMLSerializer();
return xmlSerializer.serializeToString(svg);
}"""
)
logger.info(f"Generating {output_file_without_suffix}.svg..")
with open(f"{output_file_without_suffix}.svg", "wb") as f:
Expand Down

0 comments on commit 0443865

Please sign in to comment.