Only trigger invalidate styles or layout if needed

Check if the CSS styles have changed before touching the DOM element. Without this we get a consistent flood of style invalidations and re-layouts.