Skip to content

Commit 668ee9f

Browse files
fix: use get_element_bbox() in connectors rather than bbox()
1 parent a2e35f9 commit 668ee9f

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- Fixed: inconsistent polyline connectors with endpoints into transformed
11+
groups.
12+
1013
## [0.26.0 - 2026-01-03]
1114

1215
- Fixed: location references now respect transforms which may have moved

src/elements/connector.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,11 @@ impl Connector {
329329
// inside Connector rather than evaluating it early)
330330
let midpoint =
331331
if let (Some(start_el), Some(end_el)) = (&self.start_el, &self.end_el) {
332-
let start_bb = start_el
333-
.bbox()?
332+
let start_bb = ctx
333+
.get_element_bbox(start_el)?
334334
.ok_or_else(|| Error::MissingBBox(start_el.to_string()))?;
335-
let end_bb = end_el
336-
.bbox()?
335+
let end_bb = ctx
336+
.get_element_bbox(end_el)?
337337
.ok_or_else(|| Error::MissingBBox(end_el.to_string()))?;
338338
let overlap_top = start_bb
339339
.scalarspec(ScalarSpec::Miny)
@@ -420,12 +420,12 @@ impl Connector {
420420
let mut start_el_bb = BoundingBox::new(x1, y1, x1, y1);
421421
let mut end_el_bb = BoundingBox::new(x2, y2, x2, y2);
422422
if let Some(el) = &self.start_el {
423-
if let Ok(Some(el_bb)) = el.bbox() {
423+
if let Ok(Some(el_bb)) = ctx.get_element_bbox(el) {
424424
start_el_bb = el_bb;
425425
}
426426
}
427427
if let Some(el) = &self.end_el {
428-
if let Ok(Some(el_bb)) = el.bbox() {
428+
if let Ok(Some(el_bb)) = ctx.get_element_bbox(el) {
429429
end_el_bb = el_bb;
430430
}
431431
}
@@ -439,7 +439,7 @@ impl Connector {
439439
abs_offset_set,
440440
)?;
441441

442-
// TODO: remove repeated points.
442+
// TODO: remove repeated and collinear points.
443443
if points.len() == 2 {
444444
SvgElement::new(
445445
"line",

tests/integration_tests/connector.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,15 @@ fn test_elbow_connector() {
314314
assert_contains!(output, expected1);
315315
assert_contains!(output, expected2);
316316
}
317+
318+
#[test]
319+
fn test_connector_into_relpos_group() {
320+
let input = r##"
321+
<g id="a"><rect id="a1" wh="10"/></g>
322+
<g id="b" xy="#a|h 20" dy="5"><rect id="b1" wh="10" /></g>
323+
<polyline start="#a1@r" end="#b1@l"/>
324+
"##;
325+
let expected_line = r#"<polyline points="10 5, 20 5, 20 10, 30 10"/>"#;
326+
let output = transform_str_default(input).unwrap();
327+
assert_contains!(output, expected_line);
328+
}

0 commit comments

Comments
 (0)