Skip to content

Commit ccec915

Browse files
committed
preferBinding moved to util, use hasAttribute, no need to check for modifiers
1 parent 1f7a45a commit ccec915

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

src/compiler/compile-props.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ var empty = {}
88
var identRE = require('../parsers/path').identRE
99
var settablePathRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\[[^\[\]]+\])*$/
1010

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-
2011
/**
2112
* Compile props on a root element and return
2213
* a props link function.
@@ -60,7 +51,7 @@ module.exports = function compileProps (el, propOptions) {
6051
}
6152

6253
attr = _.hyphenate(name)
63-
hasBinding = preferBinding && checkBindingAttr(el, attr) !== null
54+
hasBinding = _.preferBinding && hasBindingAttr(el, attr)
6455

6556
// first check literal version
6657
value = prop.raw = _.attr(el, attr)
@@ -131,18 +122,14 @@ module.exports = function compileProps (el, propOptions) {
131122
* @return {String} attr
132123
*/
133124

134-
function checkBindingAttr (el, attr) {
125+
function hasBindingAttr (el, attr) {
135126
if (attr === 'class') {
136-
return null
127+
return false
137128
}
138129

139130
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')
131+
el.hasAttribute(':' + attr) ||
132+
el.hasAttribute('v-bind:' + attr)
146133
)
147134
}
148135

src/util/env.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,14 @@ exports.nextTick = (function () {
8383
timerFunc(nextTickHandler, 0)
8484
}
8585
})()
86+
87+
// feature detect browsers (IE) that have trouble
88+
// with binding syntax on certain attributes
89+
var div
90+
var preferBinding = false
91+
if (inBrowser) {
92+
div = document.createElement('div')
93+
div.setAttribute(':title', '')
94+
preferBinding = div.getAttribute('title') !== null
95+
}
96+
exports.preferBinding = preferBinding

0 commit comments

Comments
 (0)