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: ensure StyleElementCustomPropertyManager works with disconnected elements #4112

Conversation

nicholasrice
Copy link
Contributor

@nicholasrice nicholasrice commented Nov 10, 2020

Description

This change adds behaviors that allows using the StyleElementCustomPropertyManager with a client element that is not connected.

fixes #4109

Motivation & context

Prior to this change, calling document.createElement('fast-design-system-provider') in FireFox would cause the StyleElementCustomPropertyManager to throw because it would attempt to access a property of null. The property is null when the <style> element provided to the manager is not connected to the DOM, which happens during programmatic creation of the fast-design-system-provider because the DSP itself is disconnected from the DOM.

This change checks if the problematic property is null, and if so, it attaches a subscriber to the isConnected property of the element's controller. When the subscriber invokes, only then is the customPropertyTarget accessed and assigned.

Issue type checklist

  • Chore: A change that does not impact distributed packages.
  • Bug fix: A change that fixes an issue, link to the issue above.
  • New feature: A change that adds functionality.

Is this a breaking change?

  • This change causes current functionality to break.

Adding or modifying component(s) in @microsoft/fast-components checklist

Process & policy checklist

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Copy link
Contributor

@EisenbergEffect EisenbergEffect left a comment

Choose a reason for hiding this comment

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

Just one thing I'm not quite sure about. If we can resolve that, I can approve.

Copy link
Contributor

@marjonlynch marjonlynch left a comment

Choose a reason for hiding this comment

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

This definitely fixes the issue in firefox, smoked

@EisenbergEffect EisenbergEffect added this to the Release 2020-10 milestone Nov 16, 2020
@EisenbergEffect EisenbergEffect self-requested a review November 16, 2020 21:33
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.

Programtically creating a DesignSystemProvider element throws in FF
5 participants