@@ -877,6 +877,23 @@ CompilerProto.setupElement = function (options) {
877877 ? document . querySelector ( options . el )
878878 : options . el || document . createElement ( options . tagName || 'div' )
879879
880+ var template = options . template
881+ if ( template ) {
882+ // replace option: use the first node in
883+ // the template directly
884+ if ( options . replace && template . childNodes . length === 1 ) {
885+ var replacer = template . childNodes [ 0 ] . cloneNode ( true )
886+ if ( el . parentNode ) {
887+ el . parentNode . insertBefore ( replacer , el )
888+ el . parentNode . removeChild ( el )
889+ }
890+ el = replacer
891+ } else {
892+ el . innerHTML = ''
893+ el . appendChild ( template . cloneNode ( true ) )
894+ }
895+ }
896+
880897 // apply element options
881898 if ( options . id ) el . id = options . id
882899 if ( options . className ) el . className = options . className
@@ -887,12 +904,6 @@ CompilerProto.setupElement = function (options) {
887904 }
888905 }
889906
890- // initialize template
891- var template = options . template
892- if ( template ) {
893- el . innerHTML = ''
894- el . appendChild ( template . cloneNode ( true ) )
895- }
896907 return el
897908}
898909
@@ -2148,10 +2159,14 @@ module.exports = {
21482159 return makeGetter ( 'return ' + exp , exp )
21492160 }
21502161 vars = utils . unique ( vars )
2151- var pathRE = new RegExp ( "\\b(" + vars . join ( '|' ) + ")[$\\w\\.]*\\b" , 'g' ) ,
2152- body = 'return ' + exp . replace ( pathRE , function ( path ) {
2153- return 'this.' + getRel ( path , compiler ) + path
2162+ var accessors = '' ,
2163+ pathRE = new RegExp ( "\\b(" + vars . join ( '|' ) + ")[$\\w\\.]*\\b" , 'g' ) ,
2164+ body = 'return ' + exp . replace ( pathRE , function ( path ) {
2165+ var val = 'this.' + getRel ( path , compiler ) + path
2166+ accessors += val + ';'
2167+ return val
21542168 } )
2169+ body = accessors + body
21552170 return makeGetter ( body , exp )
21562171 }
21572172}
@@ -2854,13 +2869,10 @@ module.exports = {
28542869require . register ( "seed/src/directives/on.js" , function ( exports , require , module ) {
28552870var utils = require ( '../utils' )
28562871
2857- function delegateCheck ( current , top , identifier ) {
2858- if ( current [ identifier ] ) {
2859- return current
2860- } else if ( current === top || ! current . parentNode ) {
2861- return false
2862- } else {
2863- return delegateCheck ( current . parentNode , top , identifier )
2872+ function delegateCheck ( el , root , identifier ) {
2873+ while ( el && el !== root ) {
2874+ if ( el [ identifier ] ) return el
2875+ el = el . parentNode
28642876 }
28652877}
28662878
@@ -2980,10 +2992,15 @@ module.exports = {
29802992 try {
29812993 cursorPos = el . selectionStart
29822994 } catch ( e ) { }
2983- self . vm . $set ( self . key , el [ attr ] )
2984- if ( cursorPos !== undefined ) {
2985- el . setSelectionRange ( cursorPos , cursorPos )
2986- }
2995+ // `input` event has weird updating issue with
2996+ // International (e.g. Chinese) input methods,
2997+ // have to use a Timeout to hack around it...
2998+ setTimeout ( function ( ) {
2999+ self . vm . $set ( self . key , el [ attr ] )
3000+ if ( cursorPos !== undefined ) {
3001+ el . setSelectionRange ( cursorPos , cursorPos )
3002+ }
3003+ } , 0 )
29873004 }
29883005 : function ( ) {
29893006 // no filters, don't let it trigger update()
0 commit comments