Can't update DOM-node attr while using {{}} expression #12813
Description
There is a kind of race condition between dom-node attr internal recalculation when we are using {{}}-expression and dom-node attr external modifying. This topic is based on #12763 issue and also related to #9109 issue. Also I'd like to thank @gkalpak for he clarified a problem.
Here is a little repro on this issue: http://jsfiddle.net/dhilt/8tceyw2w/9/
I have an element with style-attr contains {{}}-expression:
<div id="myElement" style="padding-left: 15px; color:{{toggle ? 'red' : 'black' }}">
and I want to play with some style property which isn't presented in the markup:
document.getElementById('myElement').style.paddingTop = '20px';
Let's run the demo!
1. Initial state. Before 1st digest ends.
Run the demo. Get the alert before out from $watch.
We see that both of padding-left and padding-top properties are set to 15 and 20 px.
And all of them are applied properly; we can see it despite the UI data is still unbound cause of alert-interruption.
2. Initial state. The end of initial digest.
Close the alert. Let the 1st digest cycle end.
See that padding-top is no longer applied to the element.
Something is broken and initial template's value of style-attr has a destructive priority over further updates on it.
3. Recalculate style expression via $scope.toggle changing.
Click on checkbox, start the new digest cycle.
We see that there is no problem with inline padding-left property.
But padding-top property is completely removed from element's style. Just an empty string.
And myElementStyle.paddingTop = '20px'
within $watch doesn't work.
.
Thanks and good luck)