Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE title binding issue #1639

Merged
merged 2 commits into from
Oct 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/compiler/compile-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function compileProps (el, propOptions) {
var props = []
var names = Object.keys(propOptions)
var i = names.length
var options, name, attr, value, path, parsed, prop
var options, name, attr, value, path, parsed, prop, isTitleBinding
while (i--) {
name = names[i]
options = propOptions[name] || empty
Expand Down Expand Up @@ -50,10 +50,16 @@ module.exports = function compileProps (el, propOptions) {
mode: propBindingModes.ONE_WAY
}

// IE title issues
isTitleBinding = false
if (name === 'title' && (el.getAttribute(':title') || el.getAttribute('v-bind:title'))) {
isTitleBinding = true
}

// first check literal version
attr = _.hyphenate(name)
value = prop.raw = _.attr(el, attr)
if (value === null) {
if (value === null || isTitleBinding) {
// then check dynamic version
if ((value = _.getBindAttr(el, attr)) === null) {
if ((value = _.getBindAttr(el, attr + '.sync')) !== null) {
Expand Down
44 changes: 44 additions & 0 deletions test/unit/specs/misc_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,48 @@ describe('Misc', function () {
})
expect(hasWarned(__, 'Unknown custom element')).toBe(true)
})

it('prefer bound title over static title', function (done) {
var el = document.createElement('div')
var count = 0
var expected = [
'bound',
'bound',
'static',
'bound',
'bound'
]
function check (title) {
expect(title).toBe(expected[count])
count++
if (count === 4) {
done()
}
}

document.body.appendChild(el)

new Vue({
el: el,
template:
'<div>\
<comp v-bind:title="title"></comp>\
<comp title="static" v-bind:title="title"></comp>\
<comp title="static"></comp>\
<comp :title="title"></comp>\
<comp title="static" :title="title"></comp>\
</div>',
data: {
title: 'bound'
},
components: {
comp: {
props: ['title'],
ready: function () {
check(this.title)
}
}
}
})
})
})