Skip to content

Commit

Permalink
[CHORE] swap flt-seo tag with div (#72)
Browse files Browse the repository at this point in the history
* [CHORE] swap flt-seo tag with div

* no message
  • Loading branch information
krokyze authored Mar 31, 2024
1 parent 7715382 commit afaf6b0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
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

0 comments on commit afaf6b0

Please sign in to comment.