Comments (2)
A test for browsercore:
diff --git a/src/xhr/xhr.zig b/src/xhr/xhr.zig
index 90150e4..cc4c42b 100644
--- a/src/xhr/xhr.zig
+++ b/src/xhr/xhr.zig
@@ -827,4 +827,16 @@ pub fn testExecFn(
.{ .src = "req4.responseText.length > 64", .ex = "true" },
};
try checkCases(js_env, &post);
+
+ var cbk = [_]Case{
+ .{ .src = "const req5 = new XMLHttpRequest()", .ex = "undefined" },
+ .{ .src = "req5.open('GET', 'http://httpbin.io/json')", .ex = "undefined" },
+ .{ .src = "var status = 0; req5.onload = () { status = this.status };", .ex = "undefined" },
+ .{ .src = "req5.send()", .ex = "undefined" },
+
+ // Each case executed waits for all loop callaback calls.
+ // So the url has been retrieved.
+ .{ .src = "status", .ex = "200" },
+ };
+ try checkCases(js_env, &cbk);
}
from zig-js-runtime.
The spec for events says:
Invoke callback with one argument, the value of which is the Event object event, with the callback this value set to event's currentTarget. Let return value be the callback's return value. [WEBIDL]
https://html.spec.whatwg.org/#event-handler-attributes
this
in MDN ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this and paragraph about DOM events: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#this_in_dom_event_handlers
When a function is used as an event handler, its this parameter is bound to the DOM element on which the listener is placed (some browsers do not follow this convention for listeners added dynamically with methods other than addEventListener()).
from zig-js-runtime.
Related Issues (20)
- Move nat_ctx creation from Env.init to Env.start
- Throw a JS exception when an func arg is not compatible with native type HOT 1
- v8 crashes when an js obj argument isn't an expected native object
- getNativeObject: ensure the js object corresponds to the expected native type
- console.log does not work on tests
- return a disposable string
- a setter without getter should generate an error
- setter can't handle Callback argument HOT 1
- getter can't return a Callback
- Cancellable IO HOT 1
- Create and expose a user context
- Init js env context with a native global object HOT 1
- Can't return a std.json.Value
- No memory layout guarantee with zig structs
- Release code
- Array like syntax support v2
- ci: error.PermissionDenied on syscall during zig-test wokflow
- Handle []T return
- panic when retrieving stack trace HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zig-js-runtime.