Skip to content

Add missing core detach and layout parity helpers#68

Merged
JosunLP merged 5 commits intodevelopmentfrom
copilot/expand-existing-modules-api
Mar 25, 2026
Merged

Add missing core detach and layout parity helpers#68
JosunLP merged 5 commits intodevelopmentfrom
copilot/expand-existing-modules-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

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

    • Added detach(), index(), contents(), offsetParent(), position(), outerWidth(includeMargin?), and outerHeight(includeMargin?) to BQueryElement
    • Added matching first-element semantics for the same APIs on BQueryCollection
    • Kept return shapes aligned with the existing wrapper style (this for mutating methods, safe defaults for empty collections)
  • Sizing behavior

    • Implemented outer size helpers using layout-box semantics via offsetWidth / offsetHeight
    • Added optional margin inclusion for parity with jQuery-style outerWidth(true) / outerHeight(true)
  • Shared core helper

    • Moved outer-size calculation into src/core/shared.ts
    • Reused the shared helper from both wrapper classes to avoid duplicated layout logic
  • Coverage and docs

    • Added targeted tests for:
      • detach/re-attach behavior
      • sibling indexing
      • text-node-inclusive contents()
      • offset parent / position lookup
      • outer size with and without margins
      • empty-collection defaults
    • Updated docs/guide/api-core.md to document the new methods

Example:

const item = $('#item');

const idx = item.index();
const nodes = item.contents();
const parent = item.offsetParent();
const pos = item.position();
const width = item.outerWidth(true);

item.detach();
document.body.appendChild(item.raw);

Copilot AI and others added 2 commits March 24, 2026 15:22
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
@JosunLP JosunLP marked this pull request as ready for review March 24, 2026 15:30
Copilot AI review requested due to automatic review settings March 24, 2026 15:30
@github-actions github-actions bot added core Changes to the core module docs Changes to the documentation tests Chenges to the tests labels Mar 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?), and outerHeight(includeMargin?) to BQueryElement and matching first-element semantics on BQueryCollection.
  • Introduced a shared getOuterSize() helper in src/core/shared.ts to 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.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 24, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot apply changes based on the comments in this thread

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 24, 2026

@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
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot apply changes based on the comments in this thread

Applied the follow-up review fixes in 07f3062. detach() now delegates to remove() in both wrappers, and the shared outer-size margin math has been reformatted to match the repo style.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 24, 2026

@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
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot apply changes based on the comments in this thread

Applied the JSDoc indentation fixes in 8e550cb. No UI changes were involved in this follow-up.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@JosunLP JosunLP merged commit 60411eb into development Mar 25, 2026
14 checks passed
@JosunLP JosunLP deleted the copilot/expand-existing-modules-api branch March 25, 2026 10:41
JosunLP added a commit that referenced this pull request Mar 27, 2026
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to the core module docs Changes to the documentation tests Chenges to the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants