css.js 798 B

123456789101112131415161718192021222324252627
  1. /**
  2. * ESL (Enterprise Standard Loader)
  3. * Copyright 2013 Baidu Inc. All rights reserved.
  4. *
  5. * @file CSS Loader-Plugin
  6. * @author errorrik(errorrik@gmail.com)
  7. */
  8. // 构建环境暂不支持分析,为了能合并该plugin到loader里,
  9. // 只能暂时使用具名id
  10. define( 'css', {
  11. load: function ( resourceId, req, load, config ) {
  12. var link = document.createElement( 'link' );
  13. link.setAttribute( 'rel', 'stylesheet' );
  14. link.setAttribute( 'type', 'text/css' );
  15. link.setAttribute( 'href', req.toUrl( resourceId ) );
  16. var parent = document.getElementsByTagName( 'head' )[ 0 ]
  17. || document.body;
  18. parent.appendChild( link );
  19. parent = null;
  20. link = null;
  21. load( true );
  22. }
  23. } );