@@ -746,11 +746,8 @@ module.exports = function() {
746746 if ( old && old === attrs ) {
747747 console . warn ( "Don't reuse attrs object, use new object for every redraw, this will throw in next major" )
748748 }
749- if ( attrs != null ) {
750- for ( var key in attrs ) {
751- setAttr ( vnode , key , old && old [ key ] , attrs [ key ] , ns )
752- }
753- }
749+ // Some attributes may NOT be case-sensitive (e.g. data-***),
750+ // so removal should be done first to prevent accidental removal for newly setting values.
754751 var val
755752 if ( old != null ) {
756753 for ( var key in old ) {
@@ -759,6 +756,11 @@ module.exports = function() {
759756 }
760757 }
761758 }
759+ if ( attrs != null ) {
760+ for ( var key in attrs ) {
761+ setAttr ( vnode , key , old && old [ key ] , attrs [ key ] , ns )
762+ }
763+ }
762764 }
763765 function isFormAttribute ( vnode , attr ) {
764766 return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode . dom === activeElement ( vnode . dom ) || vnode . tag === "option" && vnode . dom . parentNode === activeElement ( vnode . dom )
@@ -799,6 +801,15 @@ module.exports = function() {
799801 }
800802 }
801803 } else {
804+ // Remove style properties that no longer exist.
805+ // Style properties may have two cases(dash-case and camelCase),
806+ // so removal should be done first to prevent accidental removal for newly setting values.
807+ for ( var key in old ) {
808+ if ( old [ key ] != null && style [ key ] == null ) {
809+ if ( key [ 0 ] === "-" && key [ 1 ] === "-" ) element . style . removeProperty ( key )
810+ else element . style [ key ] = ""
811+ }
812+ }
802813 // Both old & new are (different) objects.
803814 // Update style properties that have changed
804815 for ( var key in style ) {
@@ -808,13 +819,6 @@ module.exports = function() {
808819 else element . style [ key ] = value
809820 }
810821 }
811- // Remove style properties that no longer exist
812- for ( var key in old ) {
813- if ( old [ key ] != null && style [ key ] == null ) {
814- if ( key [ 0 ] === "-" && key [ 1 ] === "-" ) element . style . removeProperty ( key )
815- else element . style [ key ] = ""
816- }
817- }
818822 }
819823 }
820824
0 commit comments