Created
June 27, 2018 20:43
-
-
Save Arkmind/34ff9333f1ea11b78acb4674f4e489aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const UID = { | |
_current: 0, | |
getNew: function(){ | |
this._current++; | |
return this._current; | |
} | |
}; | |
HTMLElement.prototype.pseudoStyle = function(element, prop, value){ | |
var _this = this; | |
var _sheetId = "pseudoStyles"; | |
var _head = document.head || document.getElementsByTagName('head')[0]; | |
var _sheet = document.getElementById(_sheetId) || document.createElement('style'); | |
_sheet.id = _sheetId; | |
var className = "pseudoStyle" + UID.getNew(); | |
_this.className += " "+className; | |
_sheet.innerHTML += " ."+className+":"+element+"{"+prop+":"+value+"}"; | |
_head.appendChild(_sheet); | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment