export var SrcDocEnabled = !!('srcdoc' in document.createElement('iframe'));
/**
 * @param frame:HTMLIFrameElement
 * @param srcdoc:String
 *
 */

export default (function (frame, srcdoc, loaded) {
  frame.addEventListener('load', function once() {
    frame.removeEventListener('load', once);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    loaded.apply(this, args);
  });

  if (SrcDocEnabled) {
    frame.srcdoc = srcdoc;
  } else {
    frame.contentDocument.open();
    frame.contentDocument.write(srcdoc);
    frame.contentDocument.close();
  }
});