yewstack / yew

Rust / Wasm framework for creating reliable and efficient web applications
https://yew.rs
Apache License 2.0
30.61k stars 1.42k forks source link

if xmlns attribute is specified, use that namespace when creating ele… #3629

Open jasoncg opened 6 months ago

jasoncg commented 6 months ago

Description

This change in VTag create_element checks for the xmlns attribute. If specified, then it uses that as the namespace when creating the element.

This makes it possible to use HTML within an SVG foreignObject with the correct namespace like this:

<@{"foreignObject"} width=100 height=100 >
  <div xmlns="http://www.w3.org/1999/xhtml" style="width:20em;height:20em">
          <span>{"Test"}</span>
          <table>
                <tr>
                    <th>{"Header 1"}</th>
                    <th>{"Header 2"}</th>
                </tr>
                <tr>
                    <td>{"Test"}</td>
                    <td>{"Test"}</td>
                </tr>
          </table>
  </div>
</@>

Fixes #3034

Checklist

github-actions[bot] commented 6 months ago

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.809 ns      │ 4.818 ns      │ 3.707 ns      │ 3.44 ns       │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.808 ns      │ 3.057 ns      │ 2.818 ns      │ 2.83 ns       │ 100     │ 1000000000
github-actions[bot] commented 6 months ago

Visit the preview URL for this PR (updated for commit 03354ac):

https://yew-rs-api--pr3629-vtag-create-element-9wzoybgd.web.app

(expires Sat, 16 Mar 2024 21:00:09 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

github-actions[bot] commented 6 months ago

Size Comparison

| examples | master (KB) | pull request (KB) | diff (KB) | diff (%) | | --- | --- | --- | --- | --- | | async_clock | 98.845 | 100.232 | +1.388 | +1.404% | | boids | 171.354 | 172.739 | +1.386 | +0.809% | | communication_child_to_parent | 91.513 | 92.900 | +1.388 | +1.516% | | communication_grandchild_with_grandparent | 103.752 | 105.140 | +1.388 | +1.338% | | communication_grandparent_to_grandchild | 99.176 | 100.563 | +1.388 | +1.399% | | communication_parent_to_child | 87.859 | 89.245 | +1.386 | +1.577% | | contexts | 103.879 | 105.267 | +1.388 | +1.336% | | counter | 84.777 | 86.165 | +1.388 | +1.637% | | counter_functional | 84.903 | 86.291 | +1.388 | +1.634% | | dyn_create_destroy_apps | 87.752 | 89.140 | +1.388 | +1.581% | | file_upload | 98.939 | 100.327 | +1.388 | +1.403% | | function_memory_game | 169.629 | 171.015 | +1.386 | +0.817% | | function_router | 346.408 | 347.794 | +1.386 | +0.400% | | function_todomvc | 159.868 | 161.254 | +1.386 | +0.867% | | futures | 227.015 | 227.256 | +0.241 | +0.106% | | game_of_life | 108.243 | 109.631 | +1.388 | +1.282% | | immutable | 187.456 | 190.225 | +2.769 | +1.477% | | inner_html | 78.634 | 80.021 | +1.388 | +1.765% | | js_callback | 107.484 | 108.870 | +1.386 | +1.289% | | keyed_list | 196.810 | 198.198 | +1.389 | +0.706% | | mount_point | 81.438 | 82.825 | +1.388 | +1.704% | | nested_list | 112.511 | 113.898 | +1.388 | +1.233% | | node_refs | 88.905 | 90.293 | +1.388 | +1.561% | | password_strength | 1707.784 | 1709.170 | +1.386 | +0.081% | | portals | 92.059 | 93.446 | +1.388 | +1.507% | | router | 315.536 | 316.922 | +1.386 | +0.439% | | simple_ssr | 139.426 | 140.825 | +1.399 | +1.004% | | ssr_router | 385.924 | 387.321 | +1.397 | +0.362% | | suspense | 113.986 | 115.372 | +1.386 | +1.216% | | timer | 87.458 | 88.846 | +1.388 | +1.587% | | timer_functional | 96.317 | 97.705 | +1.388 | +1.441% | | todomvc | 140.444 | 141.832 | +1.388 | +0.988% | | two_apps | 84.153 | 85.541 | +1.388 | +1.649% | | web_worker_fib | 133.673 | 135.061 | +1.388 | +1.038% | | web_worker_prime | 183.743 | 185.129 | +1.386 | +0.754% | | webgl | 81.282 | 82.670 | +1.388 | +1.707% |

⚠️ The following examples have changed their size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 98.845 100.232 +1.388 +1.404%
communication_child_to_parent 91.513 92.900 +1.388 +1.516%
communication_grandchild_with_grandparent 103.752 105.140 +1.388 +1.338%
communication_grandparent_to_grandchild 99.176 100.563 +1.388 +1.399%
communication_parent_to_child 87.859 89.245 +1.386 +1.577%
contexts 103.879 105.267 +1.388 +1.336%
counter 84.777 86.165 +1.388 +1.637%
counter_functional 84.903 86.291 +1.388 +1.634%
dyn_create_destroy_apps 87.752 89.140 +1.388 +1.581%
file_upload 98.939 100.327 +1.388 +1.403%
game_of_life 108.243 109.631 +1.388 +1.282%
immutable 187.456 190.225 +2.769 +1.477%
inner_html 78.634 80.021 +1.388 +1.765%
js_callback 107.484 108.870 +1.386 +1.289%
mount_point 81.438 82.825 +1.388 +1.704%
nested_list 112.511 113.898 +1.388 +1.233%
node_refs 88.905 90.293 +1.388 +1.561%
portals 92.059 93.446 +1.388 +1.507%
simple_ssr 139.426 140.825 +1.399 +1.004%
suspense 113.986 115.372 +1.386 +1.216%
timer 87.458 88.846 +1.388 +1.587%
timer_functional 96.317 97.705 +1.388 +1.441%
two_apps 84.153 85.541 +1.388 +1.649%
web_worker_fib 133.673 135.061 +1.388 +1.038%
webgl 81.282 82.670 +1.388 +1.707%
github-actions[bot] commented 6 months ago

Benchmark - SSR

Yew Master

| Benchmark | Round | Min (ms) | Max (ms) | Mean (ms) | Standard Deviation | | --- | --- | --- | --- | --- | --- | | Baseline | 10 | 308.469 | 310.912 | 309.149 | 0.654 | | Hello World | 10 | 489.576 | 503.920 | 497.376 | 4.732 | | Function Router | 10 | 1643.574 | 1682.228 | 1660.054 | 11.261 | | Concurrent Task | 10 | 1005.506 | 1006.915 | 1006.220 | 0.403 | | Many Providers | 10 | 1113.231 | 1170.822 | 1144.061 | 17.334 |

Pull Request

| Benchmark | Round | Min (ms) | Max (ms) | Mean (ms) | Standard Deviation | | --- | --- | --- | --- | --- | --- | | Baseline | 10 | 301.436 | 309.691 | 307.408 | 3.051 | | Hello World | 10 | 476.707 | 487.620 | 484.443 | 3.446 | | Function Router | 10 | 1623.491 | 1652.701 | 1641.005 | 9.396 | | Concurrent Task | 10 | 1005.205 | 1006.228 | 1005.791 | 0.314 | | Many Providers | 10 | 1090.682 | 1127.247 | 1109.077 | 11.672 |
bicarlsen commented 6 months ago

Just tested this on my system and it seems to work correctly.