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

dart:html Element.setInnerHtml signature accepts null but throws if passed #41699

Closed
nshahan opened this issue Apr 28, 2020 · 2 comments
Closed
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html NNBD Issues related to NNBD Release web-libraries Issues impacting dart:html, etc., libraries

Comments

@nshahan
Copy link
Contributor

nshahan commented Apr 28, 2020

The new signature is in the Null Safe SDK is

void setInnerHtml(String? html,
      {NodeValidator? validator, NodeTreeSanitizer? treeSanitizer})

But within the body html! appears which causes an error when you pass null.

Repro:

import 'dart:html';

main() {
  document.body!.setInnerHtml(null);
}

Compiling with DDC and running in a browser will cause the error:
Uncaught Error: NoSuchMethodError: '<Unexpected Null Value>'

cc @srujzs

@nshahan nshahan added web-libraries Issues impacting dart:html, etc., libraries library-html area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. NNBD Issues related to NNBD Release labels Apr 28, 2020
@nshahan
Copy link
Contributor Author

nshahan commented Apr 28, 2020

I forgot to mention it looks like with the current SDK this would result in the string "null" being inserted as the inner HTML.

@srujzs
Copy link
Contributor

srujzs commented Apr 28, 2020

Thanks for filing this. We've discussed potentially either clearing the innerHtml string or forwarding the null string to createFragment but it's not sure what the effects of either of these decisions are. It's possible createFragment is typed incorrectly as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html NNBD Issues related to NNBD Release web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

2 participants