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: web-components element rendering exception #1903

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

wang1212
Copy link
Member

@wang1212 wang1212 commented Feb 7, 2025

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / Document optimization
  • TypeScript definition update
  • Refactoring
  • Performance improvement
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

#1882

💡 Background and solution

see #1882 , since the G engine has abandoned support for numerical units in element attribute values, the official documentation examples need to be updated to ensure normal rendering.

On the other hand, the g-html element cannot be rendered on the first screen because the rendering logic only occurs when the attributes are updated. By default, triggering a rendering once can solve the problem.

📝 Changelog

Language Changelog
🇺🇸 English fix: web-components element rendering exception
🇨🇳 Chinese fix: web-components 元素渲染异常

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

Walkthrough

This pull request addresses a rendering exception in web-components by updating the rendering logic for g-html elements and ensuring compatibility with the G engine's new attribute value handling. It includes updates to demos and tests to reflect these changes.

Changes

Files Summary
.changeset/pretty-crews-itch.md Added a changeset for the patch fix.
tests/demos/bugfix/1176.ts, tests/demos/bugfix/1882.ts, tests/demos/bugfix/index.ts Added new test cases for issues #1176 and #1882.
packages/g-web-components/src/shape/HTML.ts Modified the HTMLShape class to update HTML content on initialization and attribute changes.
site/examples/ecosystem/declarative/demo/web-components-react.tsx, site/examples/ecosystem/declarative/demo/web-components.js Updated demo files to remove numerical units from attribute values.

});
observer.observe(this, {
characterData: true,
childList: true,
characterDataOldValue: true,
});

updateHTML(this);

Choose a reason for hiding this comment

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

Ensure that updateHTML(this) is called after the observer is set up to guarantee that the initial HTML content is rendered correctly.

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.

1 participant