@@ -8,6 +8,15 @@ var empty = {}
8
8
var identRE = require ( '../parsers/path' ) . identRE
9
9
var settablePathRE = / ^ [ A - Z a - z _ $ ] [ \w $ ] * ( \. [ A - Z a - z _ $ ] [ \w $ ] * | \[ [ ^ \[ \] ] + \] ) * $ /
10
10
11
+ // feature detect browsers (IE) that have trouble
12
+ // with binding syntax on certain attributes
13
+ var div , preferBinding
14
+ if ( _ . inBrowser ) {
15
+ div = document . createElement ( 'div' )
16
+ div . setAttribute ( ':title' , '' )
17
+ preferBinding = div . getAttribute ( 'title' ) !== null
18
+ }
19
+
11
20
/**
12
21
* Compile props on a root element and return
13
22
* a props link function.
@@ -21,7 +30,7 @@ module.exports = function compileProps (el, propOptions) {
21
30
var props = [ ]
22
31
var names = Object . keys ( propOptions )
23
32
var i = names . length
24
- var options , name , attr , value , path , parsed , prop , isTitleBinding
33
+ var options , name , attr , value , path , parsed , prop , hasBinding
25
34
while ( i -- ) {
26
35
name = names [ i ]
27
36
options = propOptions [ name ] || empty
@@ -50,16 +59,12 @@ module.exports = function compileProps (el, propOptions) {
50
59
mode : propBindingModes . ONE_WAY
51
60
}
52
61
53
- // IE title issues
54
- isTitleBinding = false
55
- if ( name === 'title' && ( el . getAttribute ( ':title' ) || el . getAttribute ( 'v-bind:title' ) ) ) {
56
- isTitleBinding = true
57
- }
62
+ attr = _ . hyphenate ( name )
63
+ hasBinding = preferBinding && checkBindingAttr ( el , attr ) !== null
58
64
59
65
// first check literal version
60
- attr = _ . hyphenate ( name )
61
66
value = prop . raw = _ . attr ( el , attr )
62
- if ( value === null || isTitleBinding ) {
67
+ if ( value === null || hasBinding ) {
63
68
// then check dynamic version
64
69
if ( ( value = _ . getBindAttr ( el , attr ) ) === null ) {
65
70
if ( ( value = _ . getBindAttr ( el , attr + '.sync' ) ) !== null ) {
@@ -119,6 +124,28 @@ module.exports = function compileProps (el, propOptions) {
119
124
return makePropsLinkFn ( props )
120
125
}
121
126
127
+ /**
128
+ * Check existance of an attribute with binding syntax.
129
+ *
130
+ * @param {Element } el
131
+ * @return {String } attr
132
+ */
133
+
134
+ function checkBindingAttr ( el , attr ) {
135
+ if ( attr === 'class' ) {
136
+ return null
137
+ }
138
+
139
+ return (
140
+ el . getAttribute ( ':' + attr ) ||
141
+ el . getAttribute ( ':' + attr + '.once' ) ||
142
+ el . getAttribute ( ':' + attr + '.sync' ) ||
143
+ el . getAttribute ( 'v-bind:' + attr ) ||
144
+ el . getAttribute ( 'v-bind:' + attr + '.once' ) ||
145
+ el . getAttribute ( 'v-bind:' + attr + '.sync' )
146
+ )
147
+ }
148
+
122
149
/**
123
150
* Build a function that applies props to a vm.
124
151
*
0 commit comments