Skip to content

Commit 9ec33e7

Browse files
committed
Refactor/simplify output info sending logic; rely on ResizeObserver/IntersectionObserver to send size/hidden state
1 parent bd9f049 commit 9ec33e7

File tree

14 files changed

+867
-614
lines changed

14 files changed

+867
-614
lines changed

inst/www/shared/shiny.js

Lines changed: 622 additions & 249 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.min.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

srcts/src/shiny/bind.ts

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
InputValidateDecorator,
88
} from "../inputPolicies";
99
import { shinyAppBindOutput, shinyAppUnbindOutput } from "./initedMethods";
10-
import { sendImageSizeFns } from "./sendImageSize";
10+
import { sendOutputInfoFns } from "./sendOutputInfo";
1111

1212
const boundInputs = {};
1313

@@ -38,8 +38,6 @@ type BindInputsCtx = {
3838
inputsRate: InputRateDecorator;
3939
inputBindings: BindingRegistry<InputBinding>;
4040
outputBindings: BindingRegistry<OutputBinding>;
41-
sendOutputHiddenState: () => void;
42-
maybeAddThemeObserver: (el: HTMLElement) => void;
4341
initDeferredIframes: () => void;
4442
};
4543
function bindInputs(
@@ -120,11 +118,7 @@ function bindInputs(
120118
}
121119

122120
function bindOutputs(
123-
{
124-
sendOutputHiddenState,
125-
maybeAddThemeObserver,
126-
outputBindings,
127-
}: BindInputsCtx,
121+
{ outputBindings }: BindInputsCtx,
128122
scope: BindScope = document.documentElement
129123
): void {
130124
const $scope = $(scope);
@@ -155,12 +149,6 @@ function bindOutputs(
155149
continue;
156150
}
157151

158-
// If this element reports its CSS styles to getCurrentOutputInfo()
159-
// then it should have a MutationObserver() to resend CSS if its
160-
// style/class attributes change. This observer should already exist
161-
// for _static_ UI, but not yet for _dynamic_ UI
162-
maybeAddThemeObserver(el);
163-
164152
const bindingAdapter = new OutputBindingAdapter(el, binding);
165153

166154
shinyAppBindOutput(id, bindingAdapter);
@@ -177,8 +165,7 @@ function bindOutputs(
177165
}
178166

179167
// Send later in case DOM layout isn't final yet.
180-
setTimeout(sendImageSizeFns.regular, 0);
181-
setTimeout(sendOutputHiddenState, 0);
168+
setTimeout(sendOutputInfoFns.regular, 0);
182169
}
183170

184171
function unbindInputs(
@@ -212,7 +199,6 @@ function unbindInputs(
212199
}
213200
}
214201
function unbindOutputs(
215-
{ sendOutputHiddenState }: BindInputsCtx,
216202
scope: BindScope = document.documentElement,
217203
includeSelf = false
218204
) {
@@ -243,8 +229,7 @@ function unbindOutputs(
243229
}
244230

245231
// Send later in case DOM layout isn't final yet.
246-
setTimeout(sendImageSizeFns.regular, 0);
247-
setTimeout(sendOutputHiddenState, 0);
232+
setTimeout(sendOutputInfoFns.regular, 0);
248233
}
249234

250235
// (Named used before TS conversion)
@@ -256,13 +241,9 @@ function _bindAll(
256241
bindOutputs(shinyCtx, scope);
257242
return bindInputs(shinyCtx, scope);
258243
}
259-
function unbindAll(
260-
shinyCtx: BindInputsCtx,
261-
scope: BindScope,
262-
includeSelf = false
263-
): void {
244+
function unbindAll(scope: BindScope, includeSelf = false): void {
264245
unbindInputs(scope, includeSelf);
265-
unbindOutputs(shinyCtx, scope, includeSelf);
246+
unbindOutputs(scope, includeSelf);
266247
}
267248
function bindAll(shinyCtx: BindInputsCtx, scope: BindScope): void {
268249
// _bindAll returns input values; it doesn't send them to the server.

0 commit comments

Comments
 (0)