Browse Source

[ui] Vue 3 - Using setAttribute instead of Object.assign to set web component props

sreenaths 4 years ago
parent
commit
933cede944

+ 8 - 2
desktop/core/src/desktop/js/ko/bindings/ko.vue.js

@@ -16,17 +16,23 @@
 
 import * as ko from 'knockout';
 
+function setAttributes(el, attrs) {
+  for(var key in attrs) {
+    el.setAttribute(key, attrs[key]);
+  }
+}
+
 ko.bindingHandlers.vueKoProps = {
   init: (element, valueAccessor) => {
     const data = valueAccessor();
-    Object.assign(element, data);
+    setAttributes(element, data);
   }
 };
 
 ko.bindingHandlers.vueProps = {
   init: (element, valueAccessor) => {
     const data = valueAccessor();
-    Object.assign(element, ko.toJS(data));
+    setAttributes(element, ko.toJS(data));
   }
 };
 

+ 2 - 1
desktop/core/src/desktop/js/vue/wrapper/index.ts

@@ -88,7 +88,8 @@ export default function wrap (component: Component, eventNames: string[] = []) {
       const self = this;
       this._wrapper = createApp({
         render () {
-          return h(componentObj, Object.assign({}, self._props, eventProxies), () => self._slotChildren);
+          const props = Object.assign({}, self._props, eventProxies);
+          return h(componentObj, props, () => self._slotChildren);
         },
         mounted() {
           self._mounted = true;