@@ -68,17 +68,14 @@ Directive.prototype._bind = function () {
68
68
// 1.0.0: remove bind/on
69
69
// TODO simplify this
70
70
if ( name === 'attr' ) {
71
- this . el . removeAttribute ( 'bind-' + this . arg )
72
- this . el . removeAttribute ( ':' + this . arg )
71
+ removeBindAttr ( this . el , this . arg )
73
72
} else if ( name === 'class' || name === 'style' ) {
74
- this . el . removeAttribute ( 'bind-' + name )
75
- this . el . removeAttribute ( ':' + name )
73
+ removeBindAttr ( this . el , name )
76
74
} else if ( name === 'on' ) {
77
75
this . el . removeAttribute ( 'on-' + this . arg )
78
76
} else if ( name === 'transition' || name === 'el' ) {
79
77
if ( this . arg ) {
80
- this . el . removeAttribute ( 'bind-' + name )
81
- this . el . removeAttribute ( ':' + name )
78
+ removeBindAttr ( this . el , name )
82
79
} else {
83
80
this . el . removeAttribute ( name )
84
81
}
@@ -300,4 +297,21 @@ Directive.prototype._teardown = function () {
300
297
}
301
298
}
302
299
300
+ /**
301
+ * Check if the colon prefixed form exists before attempting
302
+ * to remove it. This is necessary because IE will remove
303
+ * the unprefixed attribute if the prefixed version is not
304
+ * present.
305
+ *
306
+ * @param {Element } el
307
+ * @param {String } name
308
+ */
309
+
310
+ function removeBindAttr ( el , name ) {
311
+ var attr = el . hasAttribute ( ':' + name )
312
+ ? ':' + name
313
+ : 'bind-' + name
314
+ el . removeAttribute ( attr )
315
+ }
316
+
303
317
module . exports = Directive
0 commit comments