Skip to content

Commit cbfc6d9

Browse files
committed
fixup type mechanism
1 parent c62ee7e commit cbfc6d9

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

R/scale-colour.R

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ scale_colour_continuous <- function(
9696
}
9797

9898
type <- type %||% "gradient"
99-
args <- list2(...)
99+
args <- list2(..., aesthetics = aesthetics, guide = guide)
100100
args$call <- args$call %||% current_call()
101101

102102
if (is.function(type)) {
103-
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
104-
args$call <- NULL
103+
if (!any(c("...") %in% fn_fmls_names(type))) {
104+
args <- args[intersect(names(args), fn_fmls_names(type))]
105105
}
106106
check_scale_type(exec(type, !!!args), "scale_colour_continuous", "colour")
107107
} else if (identical(type, "gradient")) {
@@ -137,12 +137,12 @@ scale_fill_continuous <- function(
137137
}
138138

139139
type <- type %||% "gradient"
140-
args <- list2(...)
140+
args <- list2(..., aesthetics = aesthetics, guide = guide)
141141
args$call <- args$call %||% current_call()
142142

143143
if (is.function(type)) {
144-
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
145-
args$call <- NULL
144+
if (!any(c("...") %in% fn_fmls_names(type))) {
145+
args <- args[intersect(names(args), fn_fmls_names(type))]
146146
}
147147
check_scale_type(exec(type, !!!args), "scale_fill_continuous", "fill")
148148
} else if (identical(type, "gradient")) {
@@ -159,7 +159,6 @@ scale_fill_continuous <- function(
159159

160160
#' @export
161161
#' @rdname scale_colour_continuous
162-
args <- list2(...)
163162
scale_colour_binned <- function(
164163
...,
165164
palette = NULL,
@@ -178,10 +177,11 @@ scale_colour_binned <- function(
178177
return(scale)
179178
}
180179

180+
args <- list2(..., aesthetics = aesthetics, guide = guide)
181181
args$call <- args$call %||% current_call()
182182
if (is.function(type)) {
183-
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
184-
args$call <- NULL
183+
if (!any(c("...") %in% fn_fmls_names(type))) {
184+
args <- args[intersect(names(args), fn_fmls_names(type))]
185185
}
186186
check_scale_type(exec(type, !!!args), "scale_colour_binned", "colour")
187187
} else {
@@ -226,10 +226,12 @@ scale_fill_binned <- function(
226226
)
227227
scale
228228
}
229+
230+
args <- list2(..., aesthetics = aesthetics, guide = guide)
229231
args$call <- args$call %||% current_call()
230232
if (is.function(type)) {
231-
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
232-
args$call <- NULL
233+
if (!any(c("...") %in% fn_fmls_names(type))) {
234+
args <- args[intersect(names(args), fn_fmls_names(type))]
233235
}
234236
check_scale_type(exec(type, !!!args), "scale_fill_binned", "fill")
235237
} else {
@@ -332,8 +334,8 @@ scale_colour_discrete <- function(
332334
args$call <- args$call %||% current_call()
333335

334336
if (is.function(type)) {
335-
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
336-
args$call <- NULL
337+
if (!any(c("...") %in% fn_fmls_names(type))) {
338+
args <- args[intersect(names(args), fn_fmls_names(type))]
337339
}
338340
check_scale_type(
339341
exec(type, !!!args),
@@ -370,8 +372,8 @@ scale_fill_discrete <- function(
370372
args$call <- args$call %||% current_call()
371373

372374
if (is.function(type)) {
373-
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
374-
args$call <- NULL
375+
if (!any(c("...") %in% fn_fmls_names(type))) {
376+
args <- args[intersect(names(args), fn_fmls_names(type))]
375377
}
376378
check_scale_type(
377379
exec(type, !!!args),

0 commit comments

Comments
 (0)