Skip to content

Commit

Permalink
Fixed console.log issue. Removed deprecated add/removeListener methods
Browse files Browse the repository at this point in the history
  • Loading branch information
EdCharbeneau committed Jan 28, 2022
1 parent 9f05d1f commit cb13956
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>6.0.0</Version>
<Version>6.1.0</Version>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
51 changes: 28 additions & 23 deletions BlazorSize/BlazorPro.BlazorSize.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>6.0.0</Version>
<Version>6.1.1</Version>
<Authors>Ed Charbeneau</Authors>
<Company>EdCharbeneau.com</Company>
<Description>A JavaScript interop for Blazor used to detect the browser's screen size and perform Media Query tests. BlazorSize uses the DOM API `matchMedia` to test screen size. BlazorSize was created to allow Blazor components to render adaptively.</Description>
Expand All @@ -16,33 +16,35 @@
<RepositoryUrl>https://github.com/EdCharbeneau/BlazorSize</RepositoryUrl>
<PackageTags>Blazor, JavaScript Interop</PackageTags>
<PackageReleaseNotes>
6.0.0 Fixed possible null issues. .NET 6 support. Moved APIs for bUnit to BlazorPro.BlazorSize.UnitTesting.
5.0.0 Added support for bUnit. Removed support for .NET 3.x
4.0.0 no release, aligning with .NET 5.0. Next version will no longer support .NET 3.x
3.2.0
Added service interfaces, IMediaQueryService, IResizeListener to support unit testing scenarios
Added end-to-end testing on source for QA
3.1.0
Added .NET 5 module loading for BlazorSize Resize Listener.
Fixed casing on JS modules, fixes deployment issues on Linux.
3.0.0
Added .NET 5 module loading for BlazorSize Media Queries.
2.3.0
Fixed additional regressions from 2.2.0, update recommended.
2.2.0
Fixed possible regressions, update recommended.
Updated Blazor dependencies.
2.1.1
Fixed MSBuild including *.json files breaking NuGet pkg.
2.0.0
Added MediaQueryList &amp; MediaQuery components.
6.1.1 Replaced deprecated `addListener` method. Removed console log messages, again.
6.1.0 Removed dependency for bUnit.Core. Breaking changes may occur in test projects. Removed console log messages.
6.0.0 Fixed possible null issues. .NET 6 support. Moved APIs for bUnit to BlazorPro.BlazorSize.UnitTesting.
5.0.0 Added support for bUnit. Removed support for .NET 3.x
4.0.0 no release, aligning with .NET 5.0. Next version will no longer support .NET 3.x
3.2.0
Added service interfaces, IMediaQueryService, IResizeListener to support unit testing scenarios
Added end-to-end testing on source for QA
3.1.0
Added .NET 5 module loading for BlazorSize Resize Listener.
Fixed casing on JS modules, fixes deployment issues on Linux.
3.0.0
Added .NET 5 module loading for BlazorSize Media Queries.
2.3.0
Fixed additional regressions from 2.2.0, update recommended.
2.2.0
Fixed possible regressions, update recommended.
Updated Blazor dependencies.
2.1.1
Fixed MSBuild including *.json files breaking NuGet pkg.
2.0.0
Added MediaQueryList &amp; MediaQuery components.
1.2.2
Fixes initalization issues with Client-Side Blazor
1.2.0
Full-release
</PackageReleaseNotes>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<FileVersion>6.0.0.0</FileVersion>
<AssemblyVersion>6.1.1.0</AssemblyVersion>
<FileVersion>6.1.1.0</FileVersion>
<PackageId>BlazorPro.BlazorSize</PackageId>
</PropertyGroup>

Expand Down Expand Up @@ -75,6 +77,9 @@
<Pack>False</Pack>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

<!-- static resources _content/* -->
<!-- / Nuget Info -->
Expand Down
3 changes: 2 additions & 1 deletion BlazorSize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"test": "tsc -p tsconfig.json && jest && npm run posttest",
"posttest": "rimraf scripts/tests/*.js",
"build": "tsc -p tsconfig.build.json"
"prebuild": "rimraf wwwroot",
"build": "npm run prebuild && tsc -p tsconfig.build.json"
},
"author": "",
"license": "ISC",
Expand Down
6 changes: 3 additions & 3 deletions BlazorSize/scripts/blazorSizeMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class BlazorSizeMedia {
let mq = window.matchMedia(mediaQuery);
let mediaQueryList = this.getMediaQueryListById(dotnetMql._id);
//console.log(`[BlazorSize] MediaQuery Read - media: ${mq.media} matches: ${mq.matches}`);
mq.addListener(mediaQueryList.dotnetCallback);
mq.addEventListener('change', mediaQueryList.dotnetCallback);
mediaQueryList.mediaQueries.push(mq);
return { matches: mq.matches, media: mq.media } as MediaQueryArgs;
}
Expand All @@ -57,15 +57,15 @@ export class BlazorSizeMedia {
let list = this.getMediaQueryListById(dotnetMql._id);
let queries = list.mediaQueries;
let toRemove = queries.find(q => q.media == mediaQuery);
toRemove?.removeListener(list.dotnetCallback);
toRemove?.removeEventListener('change',list.dotnetCallback);
list.mediaQueries = queries.filter(q => q.media !== toRemove?.media);
}

removeMediaQueryList(dotnetMql: any) {
// Get the media query from the list
let list = this.getMediaQueryListById(dotnetMql._id);
// Remove all event handlers
list.mediaQueries.forEach(q => q.removeListener(list.dotnetCallback));
list.mediaQueries.forEach(q => q.removeEventListener('change', list.dotnetCallback));
// Remove the item from the list
this.mediaQueryLists = this.mediaQueryLists.filter(f => f.id !== dotnetMql._id);
}
Expand Down

0 comments on commit cb13956

Please sign in to comment.