-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdom.js
37 lines (28 loc) · 979 Bytes
/
dom.js
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
var VMLCSS = 'behavior:url(#default#VML);display:inline-block;position:absolute;left:0px;top:0px;';
var styleSheet, styledTags = {}, styleTag = function(tag){
if (styleSheet) styledTags[tag] = styleSheet.addRule('av\\:' + tag, VMLCSS);
};
exports.init = function(document){
var namespaces;
try { // IE9 workaround: sometimes it throws here
namespaces = document.namespaces;
} catch (e) {
}
if (!namespaces) return false;
namespaces.add('av', 'urn:schemas-microsoft-com:vml');
namespaces.add('ao', 'urn:schemas-microsoft-com:office:office');
styleSheet = document.createStyleSheet();
styleSheet.addRule('vml', 'display:inline-block;position:relative;overflow:hidden;');
/* styleTag('skew');
styleTag('fill');
styleTag('stroke');
styleTag('path');
styleTag('textpath');
styleTag('group');*/
styleTag('vml');
return true;
};
exports.createElement = function(tag){
if (!(tag in styledTags)) styleTag(tag);
return document.createElement('av:' + tag);
};