dwyl / learn-elm-architecture-in-javascript

:unicorn: Learn how to build web apps using the Elm Architecture in "vanilla" JavaScript (step-by-step TDD tutorial)!
https://todomvc-app.herokuapp.com
GNU General Public License v2.0
213 stars 19 forks source link

Can we load the test-related Styles/Scripts using a single "loader" script? #6

Closed nelsonic closed 7 years ago

nelsonic commented 7 years ago

e.g:

function div(divid, text) {
  console.log(divid, text)
  var div = document.createElement('div');
  div.id = divid;
  if(text !== undefined) {
    var txt = document.createTextNode(text);
    div.appendChild(txt);
  }
  console.log(div);
  return div;
}

function script(src){
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.setAttribute('src', src);
  console.log(script);
  return script;
}

function style(href) {
  var link = document.createElement('link');
  link.type = 'text/css';
  link.rel = 'stylesheet';
  link.href = href;
  return link;
}
document.body.appendChild(div('qunit'));
document.body.appendChild(div('qunit-fixture'));
  document.body.appendChild(script('//cdnjs.cloudflare.com/ajax/libs/blanket.js/1.1.4/blanket.js'));
(function() {
  // Load the QUnit CSS file from CDN - Require to display our tests
  document.body.appendChild(style('//code.jquery.com/qunit/qunit-1.18.0.css'));
  document.body.appendChild(script('//code.jquery.com/qunit/qunit-1.18.0.js'));

  document.body.appendChild(script('test.js'));
})();