Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] swap flt-seo tag with div #72

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .fvm/fvm_config.json

This file was deleted.

4 changes: 4 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.19.4",
"flavors": {}
}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ unlinked.ds
unlinked_spec.ds
app.*.symbols

# FVM
.fvm/flutter_sdk
# FVM Version Cache
.fvm/
7 changes: 4 additions & 3 deletions lib/html/seo_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class _SeoControllerState extends State<SeoController> {

final _bodyValidator = NodeValidatorBuilder()
..allowHtml5(uriPolicy: _AllowAllUriPolicy())
..allowCustomElement('flt-seo')
..allowCustomElement('div', attributes: ['flt-seo'])
..allowCustomElement('noscript')
..allowCustomElement('h1', attributes: ['style'])
..allowCustomElement('h2', attributes: ['style'])
Expand Down Expand Up @@ -147,11 +147,12 @@ class _SeoControllerState extends State<SeoController> {
if (_bodyHash == hash) return;
_bodyHash = hash;

body.children.removeWhere((element) => element.localName == 'flt-seo');
body.children
.removeWhere((element) => element.attributes.containsKey('flt-seo'));

body.insertAdjacentHtml(
'afterBegin',
'<flt-seo>${html.body}</flt-seo>',
'<div flt-seo>${html.body}</div>',
validator: _bodyValidator,
);
}
Expand Down
2 changes: 1 addition & 1 deletion test/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ String? get headHtml => document.head?.children
.join('\n');

String? get bodyHtml => document.body?.children
.firstWhereOrNull((element) => element.localName == 'flt-seo')
.firstWhereOrNull((element) => element.attributes.containsKey('flt-seo'))
?.innerHtml;

Duration measure<T>(T Function() measure) {
Expand Down