|
8 | 8 |
|
9 | 9 | import type {BlockSvg} from '../../block_svg.js'; |
10 | 10 | import type {Connection} from '../../connection.js'; |
11 | | -import {FocusManager} from '../../focus_manager.js'; |
12 | 11 | import type {BlockStyle} from '../../theme.js'; |
| 12 | +import * as aria from '../../utils/aria.js'; |
13 | 13 | import * as dom from '../../utils/dom.js'; |
14 | 14 | import {Svg} from '../../utils/svg.js'; |
15 | 15 | import {PathObject as BasePathObject} from '../common/path_object.js'; |
@@ -90,20 +90,17 @@ export class PathObject extends BasePathObject { |
90 | 90 | this.setClass_('blocklySelected', enable); |
91 | 91 | if (enable) { |
92 | 92 | if (!this.svgPathSelected) { |
93 | | - this.svgPathSelected = this.svgPath.cloneNode(true) as SVGElement; |
94 | | - this.svgPathSelected.classList.add('blocklyPathSelected'); |
95 | | - // Ensure focus-specific properties don't overlap with the block's path. |
96 | | - dom.removeClass( |
97 | | - this.svgPathSelected, |
98 | | - FocusManager.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME, |
99 | | - ); |
100 | | - dom.removeClass( |
101 | | - this.svgPathSelected, |
102 | | - FocusManager.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME, |
| 93 | + this.svgPathSelected = dom.createSvgElement( |
| 94 | + Svg.PATH, |
| 95 | + { |
| 96 | + 'class': 'blocklyPath blocklyPathSelected', |
| 97 | + 'stroke': this.svgPath.getAttribute('stroke') ?? '', |
| 98 | + 'fill': this.svgPath.getAttribute('fill') ?? '', |
| 99 | + 'd': this.svgPath.getAttribute('d') ?? '', |
| 100 | + 'role': aria.Role.PRESENTATION, |
| 101 | + }, |
| 102 | + this.svgRoot, |
103 | 103 | ); |
104 | | - this.svgPathSelected.removeAttribute('tabindex'); |
105 | | - this.svgPathSelected.removeAttribute('id'); |
106 | | - this.svgRoot.appendChild(this.svgPathSelected); |
107 | 104 | } |
108 | 105 | } else { |
109 | 106 | if (this.svgPathSelected) { |
|
0 commit comments