diff --git a/packages/blockly/core/renderers/zelos/path_object.ts b/packages/blockly/core/renderers/zelos/path_object.ts index 6484be4e066..36eed1dc931 100644 --- a/packages/blockly/core/renderers/zelos/path_object.ts +++ b/packages/blockly/core/renderers/zelos/path_object.ts @@ -7,8 +7,8 @@ // Former goog.module ID: Blockly.zelos.PathObject import type {BlockSvg} from '../../block_svg.js'; -import {FocusManager} from '../../focus_manager.js'; import type {BlockStyle} from '../../theme.js'; +import {Role} from '../../utils/aria.js'; import * as dom from '../../utils/dom.js'; import {Svg} from '../../utils/svg.js'; import {PathObject as BasePathObject} from '../common/path_object.js'; @@ -89,19 +89,18 @@ export class PathObject extends BasePathObject { this.setClass_('blocklySelected', enable); if (enable) { if (!this.svgPathSelected) { - this.svgPathSelected = this.svgPath.cloneNode(true) as SVGElement; - this.svgPathSelected.classList.add('blocklyPathSelected'); - // Ensure focus-specific properties don't overlap with the block's path. - dom.removeClass( - this.svgPathSelected, - FocusManager.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME, - ); - dom.removeClass( - this.svgPathSelected, - FocusManager.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME, + // Create a shallow copy with only the attributes we need to carry over. + this.svgPathSelected = dom.createSvgElement( + Svg.PATH, + { + 'class': 'blocklyPath blocklyPathSelected', + 'stroke': this.svgPath.getAttribute('stroke') || '', + 'fill': this.svgPath.getAttribute('fill') || '', + 'd': this.svgPath.getAttribute('d') || '', + 'role': Role.PRESENTATION, + }, + this.svgRoot, ); - this.svgPathSelected.removeAttribute('tabindex'); - this.svgPathSelected.removeAttribute('id'); this.svgRoot.appendChild(this.svgPathSelected); } } else {