aboutsummaryrefslogtreecommitdiffstats
path: root/src/privateMocks.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/privateMocks.js')
-rw-r--r--src/privateMocks.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/privateMocks.js b/src/privateMocks.js
new file mode 100644
index 00000000..6d9fb34f
--- /dev/null
+++ b/src/privateMocks.js
@@ -0,0 +1,28 @@
+function createMockStyleSheet(doc, wind) {
+ doc = doc ? doc[0] : document;
+ wind = wind || window;
+
+ var node = doc.createElement('style');
+ var head = doc.getElementsByTagName('head')[0];
+ head.appendChild(node);
+
+ var ss = doc.styleSheets[doc.styleSheets.length - 1];
+
+ return {
+ addRule : function(selector, styles) {
+ try {
+ ss.insertRule(selector + '{ ' + styles + '}', 0);
+ }
+ catch(e) {
+ try {
+ ss.addRule(selector, styles);
+ }
+ catch(e) {}
+ }
+ },
+
+ destroy : function() {
+ head.removeChild(node);
+ }
+ };
+};