Try to avoid style recalculation when typing on the comment box

I think this doesn't completely work.. It reduces the amount
of unnecessary DOM changes, but there are still some more.
This commit is contained in:
Bryan Housel
2019-04-19 10:02:25 -04:00
parent ca02f7ed06
commit ae06e28f9b
2 changed files with 27 additions and 14 deletions

View File

@@ -200,19 +200,26 @@ export function uiCommit(context) {
var prose = saveSection.selectAll('.commit-info')
.data([0]);
if (prose.enter().size()) { // first time, make sure to update user details in prose
_userDetails = null;
}
prose = prose.enter()
.append('p')
.attr('class', 'commit-info')
.text(t('commit.upload_explanation'))
.merge(prose);
// always check if this has changed, but only update prose.html()
// if needed, because it can trigger a style recalculation
osm.userDetails(function(err, user) {
if (err) return;
var userLink = d3_select(document.createElement('div'));
if (_userDetails === user) return; // no change
_userDetails = user;
var userLink = d3_select(document.createElement('div'));
if (user.image_url) {
userLink
.append('img')