Blame view

node_modules/zrender/src/vml/core.js 1.2 KB
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  import env from '../core/env';
  
  
  var urn = 'urn:schemas-microsoft-com:vml';
  var win = typeof window === 'undefined' ? null : window;
  
  var vmlInited = false;
  
  export var doc = win && win.document;
  
  export function createNode(tagName) {
      return doCreateNode(tagName);
  }
  
  // Avoid assign to an exported variable, for transforming to cjs.
  var doCreateNode;
  
  if (doc && !env.canvasSupported) {
      try {
          !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn);
          doCreateNode = function (tagName) {
              return doc.createElement('<zrvml:' + tagName + ' class="zrvml">');
          };
      }
      catch (e) {
          doCreateNode = function (tagName) {
              return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">');
          };
      }
  }
  
  // From raphael
  export function initVML() {
      if (vmlInited || !doc) {
          return;
      }
      vmlInited = true;
  
      var styleSheets = doc.styleSheets;
      if (styleSheets.length < 31) {
          doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)');
      }
      else {
          // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx
          styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)');
      }
  }