Skip to content

Commit

Permalink
Add support for package:web 1.0.0 (#619)
Browse files Browse the repository at this point in the history
1.0.0 modifies innerHTML to be JSAny in order to
support trusted types, and this is the only member
that needs to be worked around to support that version.
  • Loading branch information
srujzs authored Jul 24, 2024
1 parent 6242437 commit f6eaea3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 7.2.3

* Fix an issue with checkbox list items separated with blank lines (#602).
* Require package `web: '>=0.4.2 <2.0.0'`.

## 7.2.2

Expand Down
9 changes: 8 additions & 1 deletion example/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void main() {
void _renderMarkdown([Event? event]) {
final markdown = markdownInput.value;

htmlDiv.innerHTML = md.markdownToHtml(markdown, extensionSet: extensionSet);
htmlDiv.innerHtml = md.markdownToHtml(markdown, extensionSet: extensionSet);

for (final block in htmlDiv.querySelectorAll('pre code').items) {
try {
Expand Down Expand Up @@ -139,3 +139,10 @@ extension on NamedNodeMap {
if (getNamedItem(qualifiedName) != null) removeNamedItem(qualifiedName);
}
}

extension on HTMLDivElement {
// The default implementation allows `JSAny` to support trusted types. We only
// use `String`s, so prefer this to avoid manual conversions.
@JS('innerHTML')
external set innerHtml(String value);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ dev_dependencies:
pool: ^1.5.1
tar: ^1.0.3
test: ^1.16.0
web: '>=0.4.2 <0.6.0'
web: '>=0.4.2 <2.0.0'
yaml: ^3.0.0

0 comments on commit f6eaea3

Please sign in to comment.