如何从 Tab 键顺序中删除 Bing 地图(和所有子控件)

How to remove Bing map (and all child controls) from tab order

Bing 地图控件 (Microsoft.Maps.Map) 是否提供 API 用于从 Tab 键顺序中删除自身(及其子控件)?

或者,是否有适当的回调(post 呈现)我可以用来在地图呈现自身后递归地设置所有元素的 tabIndex?

NB:我看到在构建时有选项可以指定是否渲染地图类型 selector/locate me button/zoom 按钮。但是假设我们想要呈现这些控件只是将它们从 Tab 键顺序中移除。

我设法使用 MutationObserver 实现了它:

var mapElem = document.getElementById("map");

let deferredClearTabIndexEvent: number | undefined;

if (mapElem !== null) {
    var config = { attributes: true, childList: true, subtree: true };
    var callback = () => {
        if (deferredClearTabIndexEvent === undefined) {
            deferredClearTabIndexEvent = window.setTimeout(() => {
                var elements = mapElem!.querySelectorAll("a, button, input, select, textarea, [tabindex]")
                for (var i=0; i<elements.length; i++) {
                    elements[i].setAttribute("tabIndex", "-1");
                }

                deferredClearTabIndexEvent = undefined;
            }, 0);
        }
    };

    var observer = new MutationObserver(callback);
    observer.observe(mapElem, config);
}