Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
hacky repair of CSSRule.selectorText, edge, chrome, safari
/* Copyright (c) 2016 Tobias Buschor | MIT License */
// hacky fix of CSSRule.selectorText, edge, chrome, safari,
var desc = Object.getOwnPropertyDescriptor(CSSStyleRule.prototype, 'selectorText');
var getter = desc.get;
desc.get = function(){
var str = getter.apply(this).replace(/\[([^\]]+[^\\\]]):([^\]]+)\]/g, '[$1\\:$2]');
return str;
Object.defineProperty(CSSStyleRule.prototype, 'selectorText', desc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment