@@ -687,7 +687,7 @@ module.exports = function($window) {
687
687
if ( key [ 0 ] === "o" && key [ 1 ] === "n" ) return updateEvent ( vnode , key , value )
688
688
if ( key . slice ( 0 , 6 ) === "xlink:" ) vnode . dom . setAttributeNS ( "http://www.w3.org/1999/xlink" , key . slice ( 6 ) , value )
689
689
else if ( key === "style" ) updateStyle ( vnode . dom , old , value )
690
- else if ( hasPropertyKey ( vnode , key , ns ) ) {
690
+ else if ( shouldUseProp ( vnode , key , value , ns ) ) {
691
691
if ( key === "value" ) {
692
692
// Only do the coercion if we're actually going to check the value.
693
693
/* eslint-disable no-implicit-coercion */
@@ -717,7 +717,7 @@ module.exports = function($window) {
717
717
if ( key [ 0 ] === "o" && key [ 1 ] === "n" ) updateEvent ( vnode , key , undefined )
718
718
else if ( key === "style" ) updateStyle ( vnode . dom , old , null )
719
719
else if (
720
- hasPropertyKey ( vnode , key , ns )
720
+ shouldUseProp ( vnode , key , old , ns )
721
721
&& key !== "className"
722
722
&& key !== "title" // creates "null" as title
723
723
&& ! ( key === "value" && (
@@ -776,13 +776,19 @@ module.exports = function($window) {
776
776
function isLifecycleMethod ( attr ) {
777
777
return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate"
778
778
}
779
- function hasPropertyKey ( vnode , key , ns ) {
779
+ // determine if a vDOM attr should be set as property or attribute
780
+ function shouldUseProp ( vnode , key , value , ns ) {
780
781
// Filter out namespaced keys
781
782
return ns === undefined && (
782
783
// If it's a custom element, just keep it.
783
784
vnode . tag . indexOf ( "-" ) > - 1 || vnode . attrs != null && vnode . attrs . is ||
784
785
// If it's a normal element, let's try to avoid a few browser bugs.
785
786
key !== "href" && key !== "list" && key !== "form" && key !== "width" && key !== "height" // && key !== "type"
787
+ // `m("a[download]")` would otherwilse be set to the string "true"
788
+ && ! ( key === "download" && value === true )
789
+ // `m("[spellcheck=false]")` and `m("[translate=no]")` would otherwise be paradoxically truthy
790
+ && ! ( key === "spellcheck" && typeof value === "string" )
791
+ && ! ( key === "translate" && typeof value === "string" )
786
792
// Defer the property check until *after* we check everything.
787
793
) && key in vnode . dom
788
794
}
0 commit comments