-
Notifications
You must be signed in to change notification settings - Fork 27
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
Element.replaceChildren(node1, node2, node3, ...nodes)
/ how to use Function.apply
?
#292
Comments
Using import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import 'package:web/web.dart';
void main() {
var container = document.querySelector('body') as Element;
container.callMethodVarArgs('replaceChildren'.toJS, [/* ... */]);
} Without: import 'dart:js_interop';
import 'package:web/web.dart';
void main() {
var container = document.querySelector('body') as Element;
container.jsReplaceChildren.apply(container, <JSAny?>[/* */].toJS);
}
extension on Element {
@JS('replaceChildren')
external JSFunction get jsReplaceChildren;
}
extension on JSFunction {
external R apply<R extends JSAny?>(JSAny? thisArgument, JSArray<JSAny?> arguments);
} |
@ykmnkmi nailed it. |
I also try to call
but it appends a String, not the 2 HTML elements. |
Line 1857 in c2d5f63
I believe you're coming across the same issue as #340. extension on Document {
@JS('replaceChildren')
external void replaceChildren2(JSAny node1, JSAny node2);
} |
In JS we can do:
In Dart we I tried using:
But this doesn't work, because the first argument can't be a list. So the list is converted to a String. Do my
containerForValues
ends up showing::D
The text was updated successfully, but these errors were encountered: