Add missing core detach and layout parity helpers#68
Conversation
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com> Agent-Logs-Url: https://github.com/bQuery/bQuery/sessions/a9f39627-6124-45b1-9a77-ced0cd0744de
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com> Agent-Logs-Url: https://github.com/bQuery/bQuery/sessions/a9f39627-6124-45b1-9a77-ced0cd0744de
There was a problem hiding this comment.
Pull request overview
This PR adds missing jQuery-parity DOM APIs to @bquery/bquery/core by extending BQueryElement and BQueryCollection with detach, sibling index, contents, offset-parent/position queries, and outer size helpers, plus tests and docs.
Changes:
- Added
detach(),index(),contents(),offsetParent(),position(),outerWidth(includeMargin?), andouterHeight(includeMargin?)toBQueryElementand matching first-element semantics onBQueryCollection. - Introduced a shared
getOuterSize()helper insrc/core/shared.tsto compute outer size with optional margin inclusion. - Added targeted unit tests and updated the core API guide docs to include the new methods.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/core.test.ts | Adds coverage for detach reuse, index/contents parity, offsetParent/position, outer size (with/without margins), and empty-collection defaults. |
| src/core/shared.ts | Adds getOuterSize() helper used by both wrappers for outer dimension calculations. |
| src/core/element.ts | Adds new parity APIs on BQueryElement, including outer size methods wired to getOuterSize(). |
| src/core/collection.ts | Adds new parity APIs on BQueryCollection with first-element semantics and safe defaults for empty collections. |
| docs/guide/api-core.md | Documents the newly added core wrapper methods and examples. |
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com> Agent-Logs-Url: https://github.com/bQuery/bQuery/sessions/65837124-4e3b-4226-a901-bbd1dbe33463
Applied the review-thread fixes in 70543fc. The new layout parity helpers now guard non-HTMLElement nodes and return safe defaults for SVG/non-HTML elements, with regression tests covering both BQueryElement and BQueryCollection. |
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com> Agent-Logs-Url: https://github.com/bQuery/bQuery/sessions/877f3d2d-1fa6-4af9-9e0e-c811a4f9a10d
Applied the follow-up review fixes in 07f3062. |
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com> Agent-Logs-Url: https://github.com/bQuery/bQuery/sessions/0884adf6-7871-47b2-b855-b92de2754533
Applied the JSDoc indentation fixes in 8e550cb. No UI changes were involved in this follow-up. |
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This PR fills a focused set of missing P0 core DOM-parity APIs in
@bquery/bquery/core. It rounds out the single-element and collection wrappers with jQuery-style detach, sibling index, child node access, offset-parent/position queries, and outer size helpers.Core parity surface
detach(),index(),contents(),offsetParent(),position(),outerWidth(includeMargin?), andouterHeight(includeMargin?)toBQueryElementBQueryCollectionthisfor mutating methods, safe defaults for empty collections)Sizing behavior
offsetWidth/offsetHeightouterWidth(true)/outerHeight(true)Shared core helper
src/core/shared.tsCoverage and docs
contents()docs/guide/api-core.mdto document the new methodsExample: