Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eoghanmurray/9e2bca1d589644ffb6610ddca7e3716e to your computer and use it in GitHub Desktop.
Save eoghanmurray/9e2bca1d589644ffb6610ddca7e3716e to your computer and use it in GitHub Desktop.
var xxxtime = 0;
var xxxcount = 0;
var yyytime = 0;
var yyycount = 0;
var rrwebRecord = (function () {
[...snip...]
if (m.attributeName === 'style') {
/// yyycount, yyytime, xxxcount, xxxtime are globals initialised to zero at top of file
yyycount += 1;
yyytime -= performance.now();
var old = _this.doc.createElement('span');
old.setAttribute('style', m.oldValue);
if (item.attributes['style'] === undefined) {
item.attributes['style'] = {};
}
for (var i = 0; i < target.style.length; i++) {
var pname = target.style[i];
var newValue = target.style.getPropertyValue(pname);
var newPriority = target.style.getPropertyPriority(pname);
if (newValue != old.style.getPropertyValue(pname) ||
newPriority != old.style.getPropertyPriority(pname)) {
if (newPriority == '') {
item.attributes['style'][pname] = newValue;
}
else {
item.attributes['style'][pname] = [newValue, newPriority];
}
}
}
for (var i = 0; i < old.style.length; i++) {
var pname = old.style[i];
if (target.style.getPropertyValue(pname) === '' ||
!target.style.getPropertyValue(pname)) {
item.attributes['style'][pname] = false;
}
}
yyytime += performance.now();
console.log('YYY', yyytime / yyycount, yyytime, yyycount);
xxxcount += 1;
xxxtime -= performance.now();
item.attributes[m.attributeName+'xxx'] = transformAttribute(_this.doc, m.target.tagName, m.attributeName, value);
xxxtime += performance.now();
console.log('XXX', xxxtime / xxxcount, xxxtime, xxxcount);
console.log('Slower', yyytime / xxxtime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment