pywebview icon indicating copy to clipboard operation
pywebview copied to clipboard

Add feature "innerHTML" to Element class

Open mobeetle opened this issue 1 year ago • 2 comments

Specification

  • pywebview version: 5.1
  • operating system: all
  • web renderer: Chromium

Add innerHTML to Element

Hi, it would be useful to add innerHTML getter / setter to Element class. It is often used in frontend development and in my opinion it is more useful then "text" currently implemented.

Practicalities

  • YES I am willing to work on this issue myself.

  • NO I am prepared to support this issue financially.

This monkey patch works just fine:

from webview.dom.element import Element

@property
def inner_html(self) -> str:
    return self._window.evaluate_js(f"{self._query_command}; element.innerHTML")

@inner_html.setter
def inner_html(self, html: str) -> None:
    self._window.evaluate_js(f"""{self._query_command}; element.innerHTML = `{html}`""")
    
Element.inner_html = inner_html

mobeetle avatar May 27 '24 12:05 mobeetle

Yes, why not. I suggest to use html instead of inner_html though.

r0x0r avatar May 28 '24 07:05 r0x0r

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 28 '24 02:06 github-actions[bot]

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.

github-actions[bot] avatar Jul 04 '24 02:07 github-actions[bot]