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

Support the DOM? #162

Open
xfq opened this issue Apr 23, 2021 · 10 comments
Open

Support the DOM? #162

xfq opened this issue Apr 23, 2021 · 10 comments
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. unknown/future spec

Comments

@xfq
Copy link
Member

xfq commented Apr 23, 2021

Currently, MiniApp platforms do not seem to support DOM manipulation.

MiniApps are based on Web technology, but they are different from ordinary web pages. In the browser, page rendering and JavaScript logic are executed in the same thread. However, MiniApps use multiple threads to complete the rendering of MiniApps: one thread is dedicated to rendering, which we generally call the view layer; and one or multiple thread(s) deals with data and logic, which we generally call the logic layer. Each MiniApp page can have one or multiple independent threads (also known as workers) in the logic layer. In the view layer, there is usually one thread, but some MiniApp implementations uses multiple threads to preload WebViews to improve the performance of page navigation.

These threads run concurrently and exchange data through MiniApps platform. The logic layer processes the data and sends it to the view layer, and receives feedback from the view layer.

Because the rendering and background logic processing can run concurrently, this makes the MiniApp more responsive.

In other words, the actual DOM tree exists in the rendering layer, but not in the logic layer, so the logic layer does not contain a document or window object and is not able to do DOM manipulation.

Can we consider exposing some DOM APIs to the logic layer so that MiniApps can make better use of JS libraries for the Web? And if we expose DOM APIs, what interfaces need to be exposed? Are there any performance considerations?

@xfq
Copy link
Member Author

xfq commented Apr 23, 2021

@xfq
Copy link
Member Author

xfq commented Apr 23, 2021

Another related question:

If we don't expose the DOM tree, is it possible to expose an accessibility tree for accessibility APIs to provide a representation that can be understood by assistive technologies (such as screen readers)? Can developers use JavaScript to modify the accessibility tree in a MiniApp?

@xfq xfq added the a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. label Apr 23, 2021
@zhangyongjing
Copy link
Contributor

Can we consider exposing some DOM APIs to the logic layer so that MiniApps can make better use of JS libraries for the Web? And if we expose DOM APIs, what interfaces need to be exposed? Are there any performance considerations?

Thanks for capturing this issue.
Do you have more background information about this requirement in terms of use cases and benefits? Is it for the ease of browser-based implementation of MiniApp, or for the acquaintance with traditional web developers who are more comfatible with DOM APIs?
And do you expect the DOM APIs are exposed in the native way or is it acceptable to have DOM-alike APIs?

Since in current MiniApp implementations, pages are NOT fully native HTML5, I assume supporting native DOM APIs would need certain translation/transformation.

@xfq
Copy link
Member Author

xfq commented Apr 27, 2021

Because it was proposed by the authors of MiniApp frameworks in the CJK meeting, I will try to ask them.

IMHO the biggest benefit is that website client-side JavaScript code can run in a MiniApp with few modifications.

@marcoscaceres
Copy link
Member

Sorry for my ignorance, but MiniApps don't support HTML and JavaScript?

@zhangyongjing
Copy link
Contributor

Sorry for my ignorance, but MiniApps don't support HTML and JavaScript?

MiniApps do support JS but not native HTML. Currently, many pre-standard implemenations use HTML-like languages to describe the page layout and UI components (new tags and events). In order to simplify data binding and component interactions, most of them adopt a Vue-like framework that provides convenient templating mechanism ({{ }}) and advanced rendering features (something similar to v-if for 'conditional rendering', v-for for 'list rendering' ) intead of using the low-level DOM-APIs.

Note: It is a question under discussion whether MiniApps would need a new markup language or just a HTML extension.

@tomayac
Copy link

tomayac commented May 10, 2021

@marcoscaceres, I have documented the way this works today in an article (which is part of a wider series).

@zhangyongjing
Copy link
Contributor

That's a great document! Thanks @tomayac

@xfq
Copy link
Member Author

xfq commented May 20, 2021

If we don't expose the DOM tree, is it possible to expose an accessibility tree for accessibility APIs to provide a representation that can be understood by assistive technologies (such as screen readers)? Can developers use JavaScript to modify the accessibility tree in a MiniApp?

It seems that at least some MiniApp implementations support adding attributes that can be used to provide additional semantics and improve accessibility:

@xfq
Copy link
Member Author

xfq commented May 21, 2021

Filed #166 for the accessibility tree issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. unknown/future spec
Projects
None yet
Development

No branches or pull requests

4 participants