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

Align prop-attr sync scheme for all components #97

Open
7 of 9 tasks
nizniz187 opened this issue Sep 5, 2021 · 1 comment
Open
7 of 9 tasks

Align prop-attr sync scheme for all components #97

nizniz187 opened this issue Sep 5, 2021 · 1 comment
Assignees
Labels
architecture Everything about programming architecture enhancement New feature or request

Comments

@nizniz187
Copy link
Contributor

nizniz187 commented Sep 5, 2021

Followed by the MR (issue #95), the rest of the components should align with the new scheme.
The revise steps are advised as the following:

  1. Add component attributes as the static property.
  static attributes = {
    disabled: {
      name: 'disabled', defaultValue: false,  // Add observed: false if it is not intended to be observed for change
      parser: (value, attr) => AttributeParser.parseBoolAttr(
        value, attr.defaultValue
      )
    },
    name: { name: 'name' },  // Basic setting for simple as-is sync (no default value, set prop the same as attribute)
    ...
  };
  1. Add static getter observedAttributes.
  static get observedAttributes() {
    return this.getObservedAttributes(this.attributes);
  }
  1. Add custom attributeChangedCallback to update component if needed.
  attributeChangedCallback(name, oldValue, newValue) {
    ...
  }
  1. Remove the initial property settings because it will be done righter after the getters & setters bound dynamically.
  render() {
    this.checked = this.getAttribute('checked');  // This should be removed
  }

Todo list:

@nizniz187 nizniz187 added the enhancement New feature or request label Sep 5, 2021
@nizniz187 nizniz187 added this to the Architecture milestone Sep 5, 2021
@nizniz187
Copy link
Contributor Author

Add prop-attr sync for Dialog & Quote components @ 7417149

@nizniz187 nizniz187 added the architecture Everything about programming architecture label Oct 2, 2021
@nizniz187 nizniz187 modified the milestones: Architecture, Version 1.0 - Pizza 🍕 - Development Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture Everything about programming architecture enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants