<commit_before>
import detectFocus from './detect-focus';
import memorizeResult from './memorize-result';

// references to the iframe's browsing context
let _document;

export default memorizeResult(() => detectFocus({
  name: 'can-focus-in-hidden-iframe',
  element: function(wrapper) {
    const iframe = document.createElement('iframe');

    // iframe must be part of the DOM before accessing the contentWindow is possible
    wrapper.appendChild(iframe);

    const _window = iframe.contentWindow;
    _document = _window.document;

    return iframe;
  },
  mutate: function(iframe) {
    iframe.style.visibility = 'hidden';

    // writing the iframe's content is synchronous
    _document.open();
    _document.write('<input>');
    _document.close();

    return _document.querySelector('input');
  },
  validate: function() {
    const focus = _document.querySelector('input');
    return _document.activeElement === focus;
  },
}));
<commit_msg>fix(supports): append element instead of document write - closes #126 #128<commit_after>
import detectFocus from './detect-focus';
import memorizeResult from './memorize-result';

// references to the iframe's browsing context
let _document;

export default memorizeResult(() => detectFocus({
  name: 'can-focus-in-hidden-iframe',
  element: function(wrapper) {
    const iframe = document.createElement('iframe');

    // iframe must be part of the DOM before accessing the contentWindow is possible
    wrapper.appendChild(iframe);

    const _window = iframe.contentWindow;
    _document = _window.document;

    return iframe;
  },
  mutate: function(iframe) {
    iframe.style.visibility = 'hidden';

    // writing the iframe's content is synchronous
    _document.open();
    _document.close();
    const input = _document.createElement('input');
    _document.body.appendChild(input);

    return _document.querySelector('input');
  },
  validate: function() {
    const focus = _document.querySelector('input');
    return _document.activeElement === focus;
  },
}));

{'fraction_non_alphanumeric': 0.12192723697148476, 'fraction_numerical': 0.0029498525073746312, 'mean_word_length': 3.9634146341463414, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4137841', 'n_tokens_mistral': 597, 'n_tokens_neox': 549, 'n_words': 156}