summaryrefslogtreecommitdiff
path: root/javascript/videojs/src/js/utils/stylesheet.js
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/videojs/src/js/utils/stylesheet.js')
-rw-r--r--javascript/videojs/src/js/utils/stylesheet.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/javascript/videojs/src/js/utils/stylesheet.js b/javascript/videojs/src/js/utils/stylesheet.js
new file mode 100644
index 0000000..18f0773
--- /dev/null
+++ b/javascript/videojs/src/js/utils/stylesheet.js
@@ -0,0 +1,39 @@
+/**
+ * @file stylesheet.js
+ * @module stylesheet
+ */
+import document from 'global/document';
+
+/**
+ * Create a DOM style element given a className for it.
+ *
+ * @param {string} className
+ * The className to add to the created style element.
+ *
+ * @return {Element}
+ * The element that was created.
+ */
+export const createStyleElement = function(className) {
+ const style = document.createElement('style');
+
+ style.className = className;
+
+ return style;
+};
+
+/**
+ * Add text to a DOM element.
+ *
+ * @param {Element} el
+ * The Element to add text content to.
+ *
+ * @param {string} content
+ * The text to add to the element.
+ */
+export const setTextContent = function(el, content) {
+ if (el.styleSheet) {
+ el.styleSheet.cssText = content;
+ } else {
+ el.textContent = content;
+ }
+};