Skip to content

Commit ba796a3

Browse files
committed
Ensure that TextLayerBuilder works correctly without the abortSignal parameter (PR 20928 follow-up)
After the changes in PR 20928 the code no longer works correctly unless the `abortSignal` parameter is provided, which completely breaks text-selection in e.g. the standalone viewer-components with errors such as: ``` #renderTextLayer: TypeError: EventTarget.addEventListener: 'signal' member of AddEventListenerOptions is not an object. #bindMouse http://localhost:8888/web/text_layer_builder.js:173 render http://localhost:8888/web/text_layer_builder.js:128 #renderTextLayer http://localhost:8888/web/pdf_page_view.js:532 resultPromise http://localhost:8888/web/pdf_page_view.js:1184 promise callback*draw http://localhost:8888/web/pdf_page_view.js:1174 renderView http://localhost:8888/web/pdf_rendering_queue.js:219 forceRendering http://localhost:8888/web/pdf_viewer.js:2081 promise callback*forceRendering http://localhost:8888/web/pdf_viewer.js:2080 renderHighestPriority http://localhost:8888/web/pdf_rendering_queue.js:84 update http://localhost:8888/web/pdf_viewer.js:1895 onScaleChanging http://localhost:8888/web/app.js:2755 dispatch http://localhost:8888/web/event_utils.js:115 #setScaleUpdatePages http://localhost:8888/web/pdf_viewer.js:1555 #setScale http://localhost:8888/web/pdf_viewer.js:1640 set currentScaleValue http://localhost:8888/web/pdf_viewer.js:592 setInitialView http://localhost:8888/web/app.js:1969 load http://localhost:8888/web/app.js:1570 promise callback*load/< http://localhost:8888/web/app.js:1518 promise callback*load http://localhost:8888/web/app.js:1507 open http://localhost:8888/web/app.js:1255 promise callback*open http://localhost:8888/web/app.js:1253 run http://localhost:8888/web/app.js:895 webViewerLoad http://localhost:8888/web/viewer.js:366 <anonymous> http://localhost:8888/web/viewer.js:377 pdf_page_view.js:547:15 ```
1 parent ab228da commit ba796a3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

web/text_layer_builder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@ class TextLayerBuilder {
169169
#bindMouse(end) {
170170
const { div } = this;
171171
const abortSignal = this.#abortSignal;
172+
const opts = abortSignal ? { signal: abortSignal } : null;
172173

173174
div.addEventListener(
174175
"mousedown",
175176
() => {
176177
div.classList.add("selecting");
177178
},
178-
{ signal: abortSignal }
179+
opts
179180
);
180181

181182
div.addEventListener(
@@ -190,7 +191,7 @@ class TextLayerBuilder {
190191
}
191192
stopEvent(event);
192193
},
193-
{ signal: abortSignal }
194+
opts
194195
);
195196

196197
TextLayerBuilder.#textLayers.set(div, end);

0 commit comments

Comments
 (0)