Smaller solution in number of LOC would be:

```js
else if (attrName in node && node[attrName] !== dataAttr) node[attrName] = dataAttr
```

Not sure how this would impact performance because more js/dom interaction is required.