File tree Expand file tree Collapse file tree 4 files changed +6
-7
lines changed
src/BootstrapBlazor/Components/HtmlTag Expand file tree Collapse file tree 4 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 11@namespace BootstrapBlazor.Components
22@inherits BootstrapModuleComponentBase
33@attribute [BootstrapModuleAutoLoader(JSObjectReference = false, AutoInvokeInit = false, AutoInvokeDispose = false)]
4- @if (! IsAddToHead )
4+ @if (! AddToHead )
55{
66 <link @attributes =" AdditionalAttributes" href =" @GetHref()" rel =" @Rel" />
77}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public partial class Link
3434 /// <para>同时在多个组件中使用同一个样式时可以添加到 head 中,减少 DOM 节点。</para>
3535 /// </summary>
3636 [ Parameter ]
37- public bool IsAddToHead { get ; set ; } = false ;
37+ public bool AddToHead { get ; set ; } = false ;
3838
3939 [ Inject , NotNull ]
4040 private IVersionService ? VersionService { get ; set ; }
@@ -48,7 +48,7 @@ public partial class Link
4848 protected override async Task OnAfterRenderAsync ( bool firstRender )
4949 {
5050 await base . OnAfterRenderAsync ( firstRender ) ;
51- if ( IsAddToHead && firstRender )
51+ if ( AddToHead && firstRender )
5252 {
5353 var obj = new { Href = GetHref ( ) , Rel } ;
5454 await InvokeVoidAsync ( "init" , obj ) ;
Original file line number Diff line number Diff line change 11export function init ( options ) {
2- const href = options . href ;
3- const rel = options . rel ;
2+ const { href, rel } = options ;
3+ const nhref = new URL ( href , document . baseURI ) ;
44 const links = document . head . getElementsByTagName ( "link" ) ;
55 // 遍历所有link元素
66 for ( let i = 0 ; i < links . length ; i ++ ) {
77 const hlink = links [ i ] ;
8- var nhref = hlink . baseURI + href ;
98 if ( hlink . href == nhref && hlink . rel == rel ) {
109 return ;
1110 }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public void Link_IsAddToHead_True()
3737 {
3838 pb . Add ( a => a . Href , "http://www.blazor.zone" ) ;
3939 pb . Add ( a => a . Version , "20220202" ) ;
40- pb . Add ( a => a . IsAddToHead , true ) ;
40+ pb . Add ( a => a . AddToHead , true ) ;
4141 } ) ;
4242 Assert . Equal ( string . Empty , cut . Markup ) ;
4343 }
You can’t perform that action at this time.
0 commit comments