Commit 9a0ad8a
feat(runtime): add Response.ok getter per Fetch Standard §7.1 (#5016)
## Summary
Adds the `Response.ok` read-only getter to `JsResponse` in
`boa_runtime`,
aligning with the Fetch Standard §7.1.
## Changes
- **response.rs**: Added `#[boa(getter)] fn ok()` - returns `true` if
status is in the range 200–299, `false` otherwise (including no status).
## Behavior
```js
const res = new Response('body', { status: 200 });
console.log(res.ok); // true
const err = new Response('body', { status: 404 });
console.log(err.ok); // false
```
## Testing
- [x] `cargo check -p boa_runtime` passes
- [x] `cargo clippy --all-features --all-targets -- -D warnings` passes
(0 warnings)
- [x] `cargo fmt --all -- --check` passes
- [x] `cargo test -p boa_runtime` passes (70/70)
## Spec Reference
- https://fetch.spec.whatwg.org/#dom-response-ok
Co-authored-by: Nakshatra Sharma <nakshatrasharma@Nakshatras-MacBook-Air.local>1 parent 5d77cf8 commit 9a0ad8a
1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
179 | 185 | | |
180 | 186 | | |
181 | 187 | | |
| |||
0 commit comments