next-csrf
Version:
CSRF mitigation library for Next.js
26 lines (22 loc) • 892 B
JavaScript
import svg from './media/svg';
import platform from '../util/platform';
// Note: IE10 on BrowserStack does not like this test
export default {
name: 'can-focus-object-svg',
element: 'object',
mutate: function mutate(element) {
element.setAttribute('type', 'image/svg+xml');
element.setAttribute('data', svg);
element.setAttribute('width', '200');
element.setAttribute('height', '50');
},
validate: function validate(element, focusTarget, _document) {
if (platform.is.GECKO) {
// Firefox seems to be handling the object creation asynchronously and thereby produces a false negative test result.
// Because we know Firefox is able to focus object elements referencing SVGs, we simply cheat by sniffing the user agent string
return true;
}
return _document.activeElement === element;
}
};
//# sourceMappingURL=focus-object-svg.js.map