Skip to content

Commit 278dfcd

Browse files
Fix copy component to clipboard (fix #672) (#797)
1 parent 1e88b9a commit 278dfcd

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

‎src/lib/entity.js‎

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -501,35 +501,14 @@ function getUniqueId(baseId) {
501501
}
502502

503503
export function getComponentClipboardRepresentation(entity, componentName) {
504-
/**
505-
* Get the list of modified properties
506-
* @param {Element} entity Entity where the component belongs
507-
* @param {string} componentName Component name
508-
* @return {object} List of modified properties with their value
509-
*/
510-
function getModifiedProperties(entity, componentName) {
511-
var data = entity.components[componentName].data;
512-
var defaultData = entity.components[componentName].schema;
513-
var diff = {};
514-
for (var key in data) {
515-
// Prevent adding unknown attributes
516-
if (!defaultData[key]) {
517-
continue;
518-
}
519-
520-
var defaultValue = defaultData[key].default;
521-
var currentValue = data[key];
522-
523-
// Some parameters could be null and '' like mergeTo
524-
if ((currentValue || defaultValue) && currentValue !== defaultValue) {
525-
diff[key] = data[key];
526-
}
527-
}
528-
return diff;
504+
entity.flushToDOM();
505+
const data = entity.getDOMAttribute(componentName);
506+
if (!data) {
507+
return componentName;
529508
}
530509

531-
const diff = getModifiedProperties(entity, componentName);
532-
const attributes = AFRAME.utils.styleParser.stringify(diff);
510+
const schema = entity.components[componentName].schema;
511+
const attributes = stringifyComponentValue(schema, data);
533512
return `${componentName}="${attributes}"`;
534513
}
535514

0 commit comments

Comments
 (0)