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

Problem with compiling forEach() on FrozenElementList with frog #1026

Closed
munificent opened this issue Jan 3, 2012 · 3 comments
Closed

Problem with compiling forEach() on FrozenElementList with frog #1026

munificent opened this issue Jan 3, 2012 · 3 comments
Assignees
Labels
closed-obsolete Closed as the reported issue is no longer relevant

Comments

@munificent
Copy link
Member

Reported by Marcin:

var els = document.queryAll('a.add-event-handler');

els.forEach((el) {
  el.classes.remove('add-event-handler');
  el.on.click.add(onAnchorClick);
});

This works great in Dartium, but after compiling via frogc it complains with:

Uncaught NoSuchMethodException - receiver: '[object NodeList]' function name: 'iterator' arguments: []]
$throw
Object.noSuchMethod
Object.iterator$0
FrozenElementList.forEach
FrozenElementList.forEach$1

Given that it works in Dartium (and dartc as later reported) I'm guessing this is a frog bug.

@jmesserly
Copy link

Looks like a DOM/HTML issue. dart:html assumes that dart:dom's NoteList is Iterable, but it's not marked that way.

Tracing this through the call stack:
  ElementList queryAll(String selectors) {
    // TODO(jacobr): scope fix.
    return new FrozenElementList._wrap(_ptr.querySelectorAll(selectors));
  }

forEach looks like:

class FrozenElementList implements ElementList {
  final _ptr;

  FrozenElementList._wrap(this._ptr);
...
  void forEach(void f(Element element)) {
    for (var element in _ptr) {
      f(LevelDom.wrapElement(element));
    }
  }
...

dart:dom's NodeList looks like:

class NodeList native "*NodeList" {

  int length;

  Node operator[](int index) native;

  void operator[]=(int index, Node value) {
    throw new UnsupportedOperationException("Cannot assign element of immutable List.");
  }

  Node item(int index) native;

  var dartObjectLocalStorage;

  String get typeName() native;
}


Set owner to @rakudrama.
Removed Area-Frog label.
Added Area-UI label.

@vsmenon
Copy link
Member

vsmenon commented Apr 12, 2012

Removed Area-UI label.
Added Area-DOM label.

@vsmenon
Copy link
Member

vsmenon commented Jun 22, 2012

This pattern appears to work today (queryAll(...).forEach(...)) in dart2js.


Added AssumedStale label.

@munificent munificent added Type-Defect closed-obsolete Closed as the reported issue is no longer relevant labels Jun 22, 2012
dart-bot pushed a commit that referenced this issue Mar 22, 2021
2021-03-22 sgrekhov@unipro.ru Fixes #1032. Change place where analyzer expects COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
2021-03-22 sgrekhov@unipro.ru Fixes #1027. Typo fixed
2021-03-22 sgrekhov@unipro.ru Fixes #1026. Missed experimental flag added
2021-03-22 sgrekhov@unipro.ru Fixes SDK issue #45381. Use 32-bit int boundaries for 32-bit systems
2021-03-19 sgrekhov@unipro.ru #1024. Tests that plays with the integers not representable in JS moved to separate files. These files will be skipped on JS

Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: Idc63625a841f1f90b0cce5db9ca6add13e4d1192
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192303
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
dart-bot pushed a commit that referenced this issue Mar 22, 2021
This reverts commit 03e8ddd.

Reason for revert: Change to hooks does not work with Windows.

Original change's description:
> [co19] Roll co19 to ae818220b12ec9c2470519db2c7167cbe4745e12
>
> 2021-03-22 sgrekhov@unipro.ru Fixes #1032. Change place where analyzer expects COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
> 2021-03-22 sgrekhov@unipro.ru Fixes #1027. Typo fixed
> 2021-03-22 sgrekhov@unipro.ru Fixes #1026. Missed experimental flag added
> 2021-03-22 sgrekhov@unipro.ru Fixes SDK issue #45381. Use 32-bit int boundaries for 32-bit systems
> 2021-03-19 sgrekhov@unipro.ru #1024. Tests that plays with the integers not representable in JS moved to separate files. These files will be skipped on JS
>
> Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
> Change-Id: Idc63625a841f1f90b0cce5db9ca6add13e4d1192
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192303
> Reviewed-by: William Hesse <whesse@google.com>
> Commit-Queue: Alexander Thomas <athom@google.com>

TBR=whesse@google.com,athom@google.com

Change-Id: I5f66db541034377f5d68424073282080d13fd34b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try
Cq-Include-Trybots: dart2js-nnbd-linux-x64-chrome-try
Cq-Include-Trybots: ddc-nnbd-linux-release-chrome-try
Cq-Include-Trybots: front-end-nnbd-linux-release-x64-try
Cq-Include-Trybots: vm-kernel-nnbd-linux-debug-x64-try
Cq-Include-Trybots: vm-kernel-nnbd-linux-release-simarm64-try
Cq-Include-Trybots: vm-kernel-nnbd-linux-release-x64-try
Cq-Include-Trybots: vm-kernel-nnbd-mac-release-x64-try
Cq-Include-Trybots: vm-kernel-nnbd-win-release-x64-try
Cq-Include-Trybots: vm-kernel-precomp-nnbd-linux-debug-x64-try
Cq-Include-Trybots: vm-kernel-precomp-nnbd-linux-release-simarm64-try
Cq-Include-Trybots: vm-kernel-precomp-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192380
Reviewed-by: William Hesse <whesse@google.com>
dart-bot pushed a commit that referenced this issue Mar 22, 2021
This reverts commit 88ee333.

Reason for revert: Hook added by mistake removed.

Original change's description:
> Revert "[co19] Roll co19 to ae818220b12ec9c2470519db2c7167cbe4745e12"
>
> This reverts commit 03e8ddd.
>
> Reason for revert: Change to hooks does not work with Windows.
>
> Original change's description:
> > [co19] Roll co19 to ae818220b12ec9c2470519db2c7167cbe4745e12
> >
> > 2021-03-22 sgrekhov@unipro.ru Fixes #1032. Change place where analyzer expects COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
> > 2021-03-22 sgrekhov@unipro.ru Fixes #1027. Typo fixed
> > 2021-03-22 sgrekhov@unipro.ru Fixes #1026. Missed experimental flag added
> > 2021-03-22 sgrekhov@unipro.ru Fixes SDK issue #45381. Use 32-bit int boundaries for 32-bit systems
> > 2021-03-19 sgrekhov@unipro.ru #1024. Tests that plays with the integers not representable in JS moved to separate files. These files will be skipped on JS
> >
> > Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
> > Change-Id: Idc63625a841f1f90b0cce5db9ca6add13e4d1192
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192303
> > Reviewed-by: William Hesse <whesse@google.com>
> > Commit-Queue: Alexander Thomas <athom@google.com>
>
> TBR=whesse@google.com,athom@google.com
>
> Change-Id: I5f66db541034377f5d68424073282080d13fd34b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try
> Cq-Include-Trybots: dart2js-nnbd-linux-x64-chrome-try
> Cq-Include-Trybots: ddc-nnbd-linux-release-chrome-try
> Cq-Include-Trybots: front-end-nnbd-linux-release-x64-try
> Cq-Include-Trybots: vm-kernel-nnbd-linux-debug-x64-try
> Cq-Include-Trybots: vm-kernel-nnbd-linux-release-simarm64-try
> Cq-Include-Trybots: vm-kernel-nnbd-linux-release-x64-try
> Cq-Include-Trybots: vm-kernel-nnbd-mac-release-x64-try
> Cq-Include-Trybots: vm-kernel-nnbd-win-release-x64-try
> Cq-Include-Trybots: vm-kernel-precomp-nnbd-linux-debug-x64-try
> Cq-Include-Trybots: vm-kernel-precomp-nnbd-linux-release-simarm64-try
> Cq-Include-Trybots: vm-kernel-precomp-nnbd-linux-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192380
> Reviewed-by: William Hesse <whesse@google.com>

# Not skipping CQ checks because this is a reland.

Change-Id: Ie54fde2d92d1b2cdb3b70835f1f8c17e3c5ac477
Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192384
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant
Projects
None yet
Development

No branches or pull requests

4 participants