Skip to content

Commit 6388981

Browse files
committed
safely handles trailing args for backwards compatibility
1 parent 5f6d3c5 commit 6388981

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

R/scale-colour.R

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ scale_colour_continuous <- function(..., palette = NULL, aesthetics = "colour",
8383
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
8484

8585
if (has_old_args || (!is.null(type) && is.null(palette))) {
86-
scale <- scale_backward_compatibility(
87-
..., guide = guide, na.value = na.value, scale = type,
86+
scale <- inject(scale_backward_compatibility(
87+
!!!list2(...),
88+
guide = guide, na.value = na.value, scale = type,
8889
aesthetic = "colour", type = "continuous"
89-
)
90+
))
9091
return(scale)
9192
}
9293
palette <- if (!is.null(palette)) as_continuous_pal(palette)
@@ -107,10 +108,11 @@ scale_fill_continuous <- function(..., palette = NULL, aesthetics = "fill", guid
107108
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
108109

109110
if (has_old_args || (!is.null(type) && is.null(palette))) {
110-
scale <- scale_backward_compatibility(
111-
..., guide = guide, na.value = na.value, scale = type,
111+
scale <- inject(scale_backward_compatibility(
112+
!!!list2(...),
113+
guide = guide, na.value = na.value, scale = type,
112114
aesthetic = "fill", type = "continuous"
113-
)
115+
))
114116
return(scale)
115117
}
116118
palette <- if (!is.null(palette)) as_continuous_pal(palette)
@@ -131,10 +133,11 @@ scale_colour_binned <- function(..., palette = NULL, aesthetics = "colour", guid
131133
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
132134

133135
if (has_old_args || (!is.null(type) && is.null(palette))) {
134-
scale <- scale_backward_compatibility(
135-
..., guide = guide, na.value = na.value, scale = type,
136+
scale <- inject(scale_backward_compatibility(
137+
!!!list2(...),
138+
guide = guide, na.value = na.value, scale = type,
136139
aesthetic = "colour", type = "binned"
137-
)
140+
))
138141
return(scale)
139142
}
140143
palette <- if (!is.null(palette)) pal_binned(as_discrete_pal(palette))
@@ -154,10 +157,11 @@ scale_fill_binned <- function(..., palette = NULL, aesthetics = "fill", guide =
154157
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
155158

156159
if (has_old_args || (!is.null(type) && is.null(palette))) {
157-
scale <- scale_backward_compatibility(
158-
..., guide = guide, na.value = na.value, scale = type,
160+
scale <- inject(scale_backward_compatibility(
161+
!!!list2(...),
162+
guide = guide, na.value = na.value, scale = type,
159163
aesthetic = "fill", type = "binned"
160-
)
164+
))
161165
return(scale)
162166
}
163167
palette <- if (!is.null(palette)) pal_binned(as_discrete_pal(palette))
@@ -214,10 +218,11 @@ scale_colour_discrete <- function(..., palette = NULL, aesthetics = "colour", na
214218
has_old_args <- any(names(enexprs(...)) %in% c("h", "c", "l", "h.start", "direction"))
215219

216220
if (has_old_args || (!is.null(type) && is.null(palette))) {
217-
scale <- scale_backward_compatibility(
218-
..., na.value = na.value, scale = type,
221+
scale <- inject(scale_backward_compatibility(
222+
!!!list2(...),
223+
na.value = na.value, scale = type,
219224
aesthetic = "colour", type = "discrete"
220-
)
225+
))
221226
return(scale)
222227
}
223228
palette <- if (!is.null(palette)) as_discrete_pal(palette)
@@ -237,10 +242,11 @@ scale_fill_discrete <- function(..., palette = NULL, aesthetics = "fill", na.val
237242
has_old_args <- any(names(enexprs(...)) %in% c("h", "c", "l", "h.start", "direction"))
238243

239244
if (has_old_args || (!is.null(type) && is.null(palette))) {
240-
scale <- scale_backward_compatibility(
241-
..., na.value = na.value, scale = type,
245+
scale <- inject(scale_backward_compatibility(
246+
!!!list2(...),
247+
na.value = na.value, scale = type,
242248
aesthetic = "fill", type = "discrete"
243-
)
249+
))
244250
return(scale)
245251
}
246252
palette <- if (!is.null(palette)) as_discrete_pal(palette)

0 commit comments

Comments
 (0)