Skip to content

Refactoring for includePanelProcessor and MdAttributeRenderer #1817

@jovyntls

Description

@jovyntls

Is your request related to a problem?
These classes could use some refactoring (details below) following #1780 where a few helper functions were created but have not been implemented throughout. The code review for this PR pointed out some improvements that could be made for related methods as well.

Describe the solution you'd like

Suggestions MdAttributeRenderer:

  • attributeSlotElement in processAttributeWithoutOverride can use the createSlotTemplateNode function in elements.js
  • hasSlotOverridingAttribute can be used in other processor functions, e.g. processDropdownAttributes, to reduce code duplication

Suggestions includePanelProcessor:
In the code review for popovers, @ryoarmanda pointed out several issues that could be applied to processInclude and processPanelSrc as well (details can be found here):

  • Early returns in places where fall-through behaviour is undesirable, e.g.
    • in processInclude, if the src attribute is found to be empty
    • in processInclude, if the maximum callstack size is exceeded
  • Consistency in the returned values: the caller of processNode expects a Context object to be returned
    • in processInclude, return node can be changed to return context
    • same for processPanelSrc
  • in processInclude, the if (isUrl) { ... } block is never reached as _getFileExistsNode above will catch any URLs first. Hence, the URL check can be moved up to before _getFileExistsNode.

Describe alternatives you've considered

N/A

Additional context

N/A

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions