Skip to content

Bug in AttributeMustacheProvider.getPossibleDirectBinding: using attrName instead of bindingName #235

@coderabbitai

Description

@coderabbitai

Description

In packages/provider.mustache/src/AttributeMustacheProvider.ts, the getPossibleDirectBinding method has a bug where it retrieves bindingName from ATTRIBUTES_BINDING_MAP but then incorrectly passes attrName to bindingHandlers.get().

This means for attributes like class, the code looks up a class handler instead of the intended css handler (since DEFAULT_ATTRIBUTE_BINDING_MAP maps 'class''css').

The method currently has a FIXME comment acknowledging this issue.

Current Behavior

getPossibleDirectBinding(attrName: string) {
  const bindingName = this.ATTRIBUTES_BINDING_MAP[attrName]
  return bindingName && this.bindingHandlers.get(attrName) //FIXME this.bindingHandlers.get(bindingName) ?
}

The mapped bindingName value is computed but never used in the lookup.

Expected Behavior

The method should use bindingName for the handler lookup so that attribute mappings work correctly.

Requirements

  • Fix the handler lookup to use the correct binding name
  • Add test case to verify the fix works correctly
  • Ensure attribute mappings like 'class' → 'css' resolve the correct handler

Context

Reported by: @phillipc
Related PR: #234
Review comment: #234 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions