@@ -64,8 +64,8 @@ public static string FormatKnockoutScript(this ParametrizedCode code, DotvvmBind
6464 /// Gets Internal.PathFragmentProperty or DataContext.KnockoutExpression. Returns null if none of these is set.
6565 /// </summary>
6666 public static string ? GetDataContextPathFragment ( this DotvvmBindableObject currentControl ) =>
67- currentControl . properties . TryGet ( Internal . PathFragmentProperty , out var pathFragment ) && pathFragment is string pathFragmentStr ? pathFragmentStr :
68- currentControl . properties . TryGet ( DotvvmBindableObject . DataContextProperty , out var dataContext ) && dataContext is IValueBinding binding ?
67+ currentControl . properties . TryGet ( DotvvmPropertyIdAssignment . PropertyIds . Internal_PathFragment , out var pathFragment ) && pathFragment is string pathFragmentStr ? pathFragmentStr :
68+ currentControl . properties . TryGet ( DotvvmPropertyIdAssignment . PropertyIds . DotvvmBindableObject_DataContext , out var dataContext ) && dataContext is IValueBinding binding ?
6969 binding . GetProperty < SimplePathExpressionBindingProperty > ( )
7070 . Code . FormatKnockoutScript ( currentControl , binding ) :
7171 null ;
@@ -88,16 +88,16 @@ internal static (int stepsUp, DotvvmBindableObject target) FindDataContextTarget
8888 if ( bindingContext == null || controlContext == null || controlContext . Equals ( bindingContext ) ) return ( 0 , control ) ;
8989
9090 var changes = 0 ;
91- foreach ( var a in control . GetAllAncestors ( includingThis : true ) )
91+ for ( var ancestor = control ; ancestor is { } ; ancestor = ancestor . Parent )
9292 {
93- var ancestorContext = a . GetDataContextType ( inherit : false ) ;
93+ var ancestorContext = ancestor . GetDataContextType ( inherit : false ) ;
9494 if ( bindingContext . Equals ( ancestorContext ) )
95- return ( changes , a ) ;
95+ return ( changes , ancestor ) ;
9696
9797 // count only client-side data contexts (DataContext={resource:} is skipped in JS)
98- if ( a . properties . TryGet ( DotvvmBindableObject . DataContextProperty , out var ancestorRuntimeContext ) )
98+ if ( ancestor . properties . TryGet ( DotvvmPropertyIdAssignment . PropertyIds . DotvvmBindableObject_DataContext , out var ancestorRuntimeContext ) )
9999 {
100- if ( a . properties . TryGet ( Internal . IsServerOnlyDataContextProperty , out var isServerOnly ) && isServerOnly != null )
100+ if ( ancestor . properties . GetOrNull ( DotvvmPropertyIdAssignment . PropertyIds . Internal_IsServerOnlyDataContext ) is { } isServerOnly )
101101 {
102102 if ( isServerOnly is false )
103103 changes ++ ;
@@ -173,9 +173,8 @@ public static T ExecDelegate<T>(this BindingDelegate<T> func, DotvvmBindableObje
173173 // this has O(h^2) complexity because GetValue calls another GetDataContexts,
174174 // but this function is used rarely - for exceptions, manually created bindings, ...
175175 // Normal bindings have specialized code generated in BindingCompiler
176- if ( c . IsPropertySet ( DotvvmBindableObject . DataContextProperty , inherit : false ) )
176+ if ( c . properties . Contains ( DotvvmPropertyIdAssignment . PropertyIds . DotvvmBindableObject_DataContext ) )
177177 {
178- Debug . Assert ( c . properties . Contains ( DotvvmBindableObject . DataContextProperty ) , "Control claims that DataContextProperty is set, but it's not present in the properties dictionary." ) ;
179178 yield return c . GetValue ( DotvvmBindableObject . DataContextProperty ) ;
180179 count -- ;
181180 }
0 commit comments