Comments (2)
To solve this issue the script must be able to run before DOMContentLoaded
- that is something we cannot guarantee as of now, thus leaving this issue open.
Here's the thing that might've worked, could it run synchronously:
define(function defineFixBrowserAutofocusTarget(require) {
'use strict';
/*
Working around an issue at page-load when the URI-fragment should make the document
scroll to an element, but another element with [autofocus] interferes.
https://code.google.com/p/chromium/issues/detail?id=382901
https://bugzilla.mozilla.org/show_bug.cgi?id=840187
*/
var isVisible = require('../dom/is-visible');
var supportsCssShadow = require('../supports/css-shadow');
if (document.readyState === 'complete') {
window.console && window.console.warn && console.warn('fix-browser/autofocus-target needs to be executed before the DOM is ready');
return;
}
function disableAutofocus() {
var id = window.location.hash.replace(/^#/, '');
if (!id) {
return;
}
// NOTE: using the <a> element to define anchros (e.g. <a name="target-id">)
// is obsolete since HTML5 and is thus not being supported here
// see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-name
var target = document.getElementById(id);
// target must exist and must be painted
if (!target || !isVisible(target)) {
return;
}
// [autofocus] in ShadowDOM will acquire focus like it were in the document itself
var selector = supportsCssShadow ? '[autofocus], ::shadow [autofocus]' : '[autofocus]';
var autofocusElements = document.querySelectorAll(selector);
// remove all [autofocus] from the document will prevent scrollElementIntoView() from happening
var disabledAutofocusElements = [].map.call(autofocusElements, function(element) {
element.removeAttribute('autofocus');
return element;
});
// restore [autofocus] elements after initial focus/positioning is done
(window.setImmediate || window.setTimeout)(function() {
disabledAutofocusElements.forEach(function(element) {
element.setAttribute('autofocus', '');
});
});
}
window.addEventListener('DOMContentLoaded', disableAutofocus, true);
});
from ally.js.
not providing this fix for now
from ally.js.
Related Issues (20)
- ally.maintain.tabFocus breaks tab in Android + Chrome HOT 6
- Error setting up focusWithin HOT 1
- Wrong focus-source on Chrome on first Input element HOT 1
- Radio groups are not considered when maintaining tab focus
- ally.query.tabsequence possible string comparison of tabindex
- Improve visuallyhidden class further HOT 4
- Fix for Firefox accidentally triggering click after focus change on space HOT 8
- Allow Option to Pass Array of Elements to Maintain Components HOT 5
- Error on Import when Running CreateReactApp Test HOT 3
- Webpack bundle
- How to trap tab focus in element but allow tabbing to browser UI? HOT 4
- Current project status HOT 1
- Feature Request(?): Ability to run the browser support tests explicitly HOT 4
- Shadow DOM elements not identified correctly as contained by a parent element for maintain.disabled
- iOS 10.3 - 11.0 ally.maintain.tabFocus OSK (OnScreenKeyboard) shows and disappear for some milliseconds HOT 1
- Dialog content not focused when opened in Mac / VoiceOver
- Platform.js vulnerability issue HOT 1
- ally.maintain.tabFocus throws error when pressing Tab inside a dialog without focusable elements
- Cannot read property '0' of null in detect-focus
- Is this library dead?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ally.js.