When compiling code with dart dart2js, and run in chrome or firefox
void main() {
window.onMouseDown.listen((e) => print(e.clientX));
}
Result:
Uncaught TypeError: undefined is not a function
In Dartium there is no error.
e.client.x should work.
e.clientX was available for a long time but deprecated. Maybe it was removed recently.
Related
I wrote simple example code in the WebStorm EAP
void main() {
var main = new Element.html('<div class="main"></div>');
document.body.children.add(main);
}
in Dartium - all is well, after pub:debug - - all is well,
but after pub:build project, in realise/index.html I do not see anything, only an error in the console:
"main.dart.js:1159 Uncaught TypeError: Cannot read property 'at' of null"
Please explain to me what is the problem, and how can I get the correct build files.
My Polymer.dart web app, that works fine in Dartium, is giving the following error (it repeats seven times) when compiled with dart2js using pub build --mode=debug and loaded in Chrome.
Resource interpreted as Script but transferred with MIME type text/plain: "http://confab.dev/index.html_bootstrap.dart". confab.dev/:10
warning: file:///home/dan/projects/confabulous/webatara/web/index.html.0.dart library not found index.html_bootstrap.dart.js:17188
Uncaught Error: NoSuchMethodError: Cannot call "get$functions" on "#<JsLibraryMirror>" (Object #<JsLibraryMirror> has no method 'get$functions') index.html_bootstrap.dart.js:17188
Stack Trace:
TypeError: Object #<JsLibraryMirror> has no method 'get$functions'
at dart._loadLibrary (http://confab.dev/index.html_bootstrap.dart.js:20000:19)
at dart._loadLibraries (http://confab.dev/index.html_bootstrap.dart.js:19917:11)
at dart._initPolymerOptimized (http://confab.dev/index.html_bootstrap.dart.js:19908:7)
at dart.initPolymer (http://confab.dev/index.html_bootstrap.dart.js:19902:7)
at main (http://confab.dev/index.html_bootstrap.dart.js:4112:7)
at _IsolateContext.eval$1 (http://confab.dev/index.html_bootstrap.dart.js:1369:23)
at dart.startRootIsolate (http://confab.dev/index.html_bootstrap.dart.js:1145:21)
at http://confab.dev/index.html_bootstrap.dart.js:26514:7
at init.currentScript (http://confab.dev/index.html_bootstrap.dart.js:26494:5)
at http://confab.dev/index.html_bootstrap.dart.js:26508:3
index.html_bootstrap.dart.js:17188
Uncaught NoSuchMethodError: Cannot call "get$functions" on "#<JsLibraryMirror>" (Object #<JsLibraryMirror> has no method 'get$functions') index.html_bootstrap.dart.js:2369
Because source maps don't appear to work (they're turned on in Chrome, and I have .map files), I don't even know which part of my code is causing this.
I've tried with interop.js included both before dart.js, as the docs say, and after, as this issue says.
Looks like a bug in dart2js. Please file an issue, ideally with a reproducible test-case.
pub upgrade fixed it. It turns out that something had replaced the polymer 0.9.5 that I'd been using with 0.8.10+4. Quite odd. The solution to this is to set the polymer version as '>= 0.9.5' instead of 'any', which I will do eventually, but for now I'm interested to see if it happens again.
Output code from dart2js throws exception before it runs my code.
Line of code: $.TimelineTween__linearEase = Z.TransitionFunction_linear$closure();
$ is undefined
Z is dart
Performed in Isolate loading.
mozilla: TypeError: Z.TransitionFunction_linear$closure is not a function
chrome: Object # has no method 'TransitionFunction_linear$closure'
I have been trying to make AngularDart work but I always get exceptions for undefined objects.
#MirrorsUsed(
targets: const [
'angular.core',
'angular.core.dom',
'angular.core.parser',
'angular.routing',
'angular.core.zone',
'di.di',
'di.dynamic_injector',
NodeTreeSanitizer,
DynamicParser,
DynamicParserBackend,
Injector
],
metaTargets: const [
NgInjectableService,
NgComponent,
NgDirective,
NgController,
NgFilter,
NgAttr,
NgOneWay,
NgOneWayOneTime,
NgTwoWay,
NgCallback,
NgZone
],
override: '*'
)
import 'dart:mirrors';
And compiled javascript showing error:
Uncaught TypeError: Cannot call method 'get$parameters' of undefined dynamic_injector.dart:42
DynamicInjector.newInstanceOf$4 dynamic_injector.dart:42
When I'm removing MirrorsUsed2 there is no errors, but compiled file is large.
Adding these helped for me
'angular.filter',
'angular.perf',
'perf_api',
and instead of angular.core.parser
'angular.core.parser.dynamic_parser'
'angular.core.parser.lexer'
I also added all my own libraries.
See also https://code.google.com/p/dart/issues/detail?id=14686
Recently, I found Dart-AngularJS when compiled not to run, even the simplest example. I reinstalled my dart sdk to the latest stable version and the errors disappeared. Could you see if this works? Please see related issue on github project.
I have a new dart project but I fail to add unit tests.
But I am new to DART so perhaps I am punished as all rookies should ... or should they!?
Error when running unit tests
Error: Exception: No constructor 'Future.value' declared in class 'Future'.
NoSuchMethodError : method not found: 'Future.value'
Receiver: Type: class 'Future'
Arguments: []
Stack Trace: #0 _defer (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:671:20)
#1 _ensureInitialized (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:830:11)
#2 ensureInitialized (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:809:21)
#3 group (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:585:20)
#4 main (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/test_runner.dart:9:8)
FAIL
pub info
€ pub --version
Pub 0.4.7+1.r21548
€ pub cache list
{"packages":
{"browser":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/browser-0.4.7+1"},
"meta":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/meta-0.4.7+1"},
"stagexl":{"version":"0.7.4","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/stagexl-0.7.4"},
"unittest":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/unittest-0.4.7+1"}}}
Eclipse plugin
Dart Editor for Eclipse 0.4.7.r21548 com.google.dart.eclipse.feature.feature.group dartlang.org
test_runner.dart
import 'package:unittest/unittest.dart';
import 'package:unittest/html_enhanced_config.dart';
import 'ChessColor_test.dart' as color_test;
void main() {
useHtmlEnhancedConfiguration();
group('Enum tests', color_test.main);
}
ChessColor_test.dart
library color_test;
import 'package:unittest/unittest.dart';
void main() {
test('isWhite', () =>
expect(true, WHITE.isWhite())
);
}
A couple of things to try:
Take a look at dart-sdk/lib/async/future.dart. Do you see a Future.value factory constructor? If not, then your SDK is not the right version. I would check this both from the command line and from within the editor.
If you do see it in the SDK, try exiting and restarting the editor. I'm speculating here, but when we saw this once in house, it behaved as though there was a cached copy of the async library that was out of date, and restarting made the issue go way.