Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: :checked attribute when set to false #12

Merged
merged 4 commits into from
Feb 14, 2024
Merged

Conversation

jorenrui
Copy link
Contributor

@jorenrui jorenrui commented Feb 14, 2024

Description

The :checked attribute is not working properly with this component:

  <div id="example" class="pt-4">
    <div class="flex">
      <input type="checkbox" :change="allChecked = this.checked;" />
      <label> Select All </label>
    </div>

    <div class="flex">
      <input type="checkbox" :checked="allChecked" />
      <label> Team 1 </label>
    </div>

    <div class="flex">
      <input type="checkbox" :checked="allChecked" />
      <label> Team 2 </label>
    </div>

    <div class="flex">
      <input type="checkbox" :checked="allChecked" />
      <label> Team 3 </label>
    </div>
  </div>

I refactored as to how :checked is evaluate. Before :checked is only set when it is true, but if it is false, it is being ignored.

📦 Published PR as canary version: 1.0.1-canary.12.9c978f6.0

✨ Test out this PR locally via:

npm install tonic-minijs@1.0.1-canary.12.9c978f6.0
# or 
yarn add tonic-minijs@1.0.1-canary.12.9c978f6.0

Summary by CodeRabbit

  • Refactor
    • Changed export declaration from default to named export for better modularity and import flexibility.
  • New Features
    • Introduced enhanced error handling capabilities in entity attributes and events processing.
  • Chores
    • Updated import statements for improved clarity and maintainability.

@jorenrui jorenrui self-assigned this Feb 14, 2024
@jorenrui jorenrui merged commit 9c978f6 into main Feb 14, 2024
1 check passed
Copy link

coderabbitai bot commented Feb 14, 2024

Walkthrough

The recent updates focus on enhancing error handling and refining export/import patterns across several modules. A significant shift from default to named exports for the Entity class improves modularity, while the addition of _handleError methods in both Attributes and Events classes bolsters error management. Moreover, adjustments in attribute evaluation processes and the adoption of destructuring for imports enhance code clarity and efficiency.

Changes

File(s) Change Summary
lib/entity.js Altered export declaration from default to named export for the Entity class.
lib/entity/attributes.js, lib/entity/events.js Introduced _handleError method for improved error handling; separated attribute evaluations; enhanced error management in methods.
lib/main.js Modified import statements to use destructuring for importing specific entities.

🐇✨
Changes afoot in the code we weave,
Named exports and errors we now can retrieve.
Through attributes and events we hop,
Catching bugs where they may pop.
Together we build, with every commit,
A garden of code, bit by bit.
🌱🚀

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@jorenrui jorenrui deleted the jr.feat/checked-attribute branch February 14, 2024 04:43
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a129aa8 and 17caa09.
Files selected for processing (4)
  • lib/entity.js (1 hunks)
  • lib/entity/attributes.js (5 hunks)
  • lib/entity/events.js (2 hunks)
  • lib/main.js (1 hunks)
Files skipped from review due to trivial changes (1)
  • lib/main.js
Additional comments: 4
lib/entity/attributes.js (2)
  • 120-130: The evaluateValue method correctly handles the evaluation of the :value attribute and logs errors using _handleError. Ensure that newValue != null is the intended condition for setting the element's value, as this would not set null or undefined values.
  • 132-142: The evaluateChecked method properly evaluates the :checked attribute and uses _handleError for error logging. Verify that the condition isChecked != null is intended to prevent setting null or undefined values to the checked property.
lib/entity/events.js (1)
  • 251-255: The error handling in evaluate method correctly uses _handleError to log errors. Verify that all event attributes are properly sanitized before interpretation to prevent potential security issues.
lib/entity.js (1)
  • 7-7: The change from default to named export for the Entity class is correctly implemented. Verify that all import statements in the codebase have been updated to reflect this change.

lib/entity/attributes.js Show resolved Hide resolved
lib/entity/attributes.js Show resolved Hide resolved
lib/entity/events.js Show resolved Hide resolved
Copy link

🚀 PR was released in v1.0.1 🚀

@github-actions github-actions bot added the released This has been released in npm label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This has been released in npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant