Skip to content

Commit 995b096

Browse files
committed
Merge pull request vuejs#1639 from fergaldoyle/dev
IE title binding issue
2 parents 87a4adf + 0061846 commit 995b096

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

src/compiler/compile-props.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = function compileProps (el, propOptions) {
2121
var props = []
2222
var names = Object.keys(propOptions)
2323
var i = names.length
24-
var options, name, attr, value, path, parsed, prop
24+
var options, name, attr, value, path, parsed, prop, isTitleBinding
2525
while (i--) {
2626
name = names[i]
2727
options = propOptions[name] || empty
@@ -50,10 +50,16 @@ module.exports = function compileProps (el, propOptions) {
5050
mode: propBindingModes.ONE_WAY
5151
}
5252

53+
// IE title issues
54+
isTitleBinding = false
55+
if (name === 'title' && (el.getAttribute(':title') || el.getAttribute('v-bind:title'))) {
56+
isTitleBinding = true
57+
}
58+
5359
// first check literal version
5460
attr = _.hyphenate(name)
5561
value = prop.raw = _.attr(el, attr)
56-
if (value === null) {
62+
if (value === null || isTitleBinding) {
5763
// then check dynamic version
5864
if ((value = _.getBindAttr(el, attr)) === null) {
5965
if ((value = _.getBindAttr(el, attr + '.sync')) !== null) {

test/unit/specs/misc_spec.js

+44
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,48 @@ describe('Misc', function () {
269269
})
270270
expect(hasWarned(__, 'Unknown custom element')).toBe(true)
271271
})
272+
273+
it('prefer bound title over static title', function (done) {
274+
var el = document.createElement('div')
275+
var count = 0
276+
var expected = [
277+
'bound',
278+
'bound',
279+
'static',
280+
'bound',
281+
'bound'
282+
]
283+
function check (title) {
284+
expect(title).toBe(expected[count])
285+
count++
286+
if (count === 4) {
287+
done()
288+
}
289+
}
290+
291+
document.body.appendChild(el)
292+
293+
new Vue({
294+
el: el,
295+
template:
296+
'<div>\
297+
<comp v-bind:title="title"></comp>\
298+
<comp title="static" v-bind:title="title"></comp>\
299+
<comp title="static"></comp>\
300+
<comp :title="title"></comp>\
301+
<comp title="static" :title="title"></comp>\
302+
</div>',
303+
data: {
304+
title: 'bound'
305+
},
306+
components: {
307+
comp: {
308+
props: ['title'],
309+
ready: function () {
310+
check(this.title)
311+
}
312+
}
313+
}
314+
})
315+
})
272316
})

0 commit comments

Comments
 (0)