Skip to content

Conversation

@stroiman
Copy link
Member

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

This PR introduces an encoder mechanism for attribute rules in the code generation system. It adds a new GoFunction type to represent Go function references with Generate() and IsZero() methods. The Encoder field is added to AttributeRule struct and integrated throughout the attribute handling pipeline, including return value generation and callback generation. The XMLHttpRequest rules are updated to encode the response attribute using EncodeString. Generic helper functions for encoding/decoding are removed in favor of centralized codec functions. Event handling is enhanced to support cancellation when listeners return false. Additionally, utility functions for type checking and a new test case for event cancellation behavior are included.

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess if a description relates to the changeset. Add a description explaining the purpose and scope of this feature, including how event listener return values affect event cancellation behavior.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Feat/event listener return value' clearly describes the main change: adding support for event listener return values to influence event cancellation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripting/internal/xhr/xmlhttp_request_generated.go (1)

203-209: response property implementation incomplete—responseType is currently ignored.

XMLHttpRequest.response should return different types depending on responseType (e.g., string for "", ArrayBuffer for "arraybuffer", Blob for "blob", parsed Object for "json" per the W3C spec). Currently, Response() always returns a string regardless of responseType. The responseType field is stored but never used to branch response handling. Using EncodeString unconditionally is inconsistent with the specification. Implement conditional response handling based on responseType value.

Comment on lines +10 to +15
func (f GoFunction) Generate() *jen.Statement {
if f.Package == "" {
return jen.Id(f.Name)
}
return jen.Qual(f.Package, f.Name)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider defensive check for empty Name.

If Generate() is called when Name is empty, it will produce jen.Id("") which may generate invalid Go code. While IsZero() exists for callers to guard against this, consider adding a defensive check or documenting the expected usage.

♻️ Optional: Add defensive handling
 func (f GoFunction) Generate() *jen.Statement {
+	if f.Name == "" {
+		return jen.Null() // or panic with descriptive message
+	}
 	if f.Package == "" {
 		return jen.Id(f.Name)
 	}
 	return jen.Qual(f.Package, f.Name)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func (f GoFunction) Generate() *jen.Statement {
if f.Package == "" {
return jen.Id(f.Name)
}
return jen.Qual(f.Package, f.Name)
}
func (f GoFunction) Generate() *jen.Statement {
if f.Name == "" {
return jen.Null() // or panic with descriptive message
}
if f.Package == "" {
return jen.Id(f.Name)
}
return jen.Qual(f.Package, f.Name)
}

@github-actions github-actions bot merged commit 637bde0 into main Jan 23, 2026
9 checks passed
@github-actions github-actions bot deleted the feat/event-listener-return-value branch January 23, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants