Skip to content

Commit 16c3084

Browse files
committed
contingency where merge_element(..., e2 = <S3_element>)
1 parent 6c13d47 commit 16c3084

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

R/theme.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,22 +999,24 @@ combine_elements <- function(e1, e2) {
999999
}
10001000
}
10011001

1002+
parent_props <- if (S7::S7_inherits(e2)) S7::props(e2) else unclass(e2)
1003+
10021004
# If e1 has any NULL properties, inherit them from e2
10031005
n <- S7::prop_names(e1)[lengths(S7::props(e1)) == 0]
1004-
S7::props(e1)[n] <- S7::props(e2)[n]
1006+
S7::props(e1)[n] <- parent_props[n]
10051007

10061008
# Calculate relative sizes
10071009
if (is_rel(try_prop(e1, "size"))) {
1008-
e1@size <- e2@size * unclass(e1@size)
1010+
e1@size <- parent_props$size * unclass(e1@size)
10091011
}
10101012

10111013
# Calculate relative linewidth
10121014
if (is_rel(try_prop(e1, "linewidth"))) {
1013-
e1@linewidth <- e2@linewidth * unclass(e1@linewidth)
1015+
e1@linewidth <- parent_props$linewidth * unclass(e1@linewidth)
10141016
}
10151017

10161018
if (is_theme_element(e1, "text")) {
1017-
e1@margin <- combine_elements(e1@margin, e2@margin)
1019+
e1@margin <- combine_elements(e1@margin, parent_props$margin)
10181020
}
10191021

10201022
# If e2 is 'richer' than e1, fill e2 with e1 parameters

0 commit comments

Comments
 (0)