JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.min.js"></script>
<output id=output></output>
JavaScript
const copiableProperties = function (object, details) {
Object.defineProperties(object, details);
object.cloneNode = (function (cloneNode) {
return function () {
const that = angular.copy(Object.assign({}, this, { cloneNode }));
Object.defineProperties(that, details);
that.cloneNode = angular.copy(this.cloneNode);
return that;
};
}(object.cloneNode));
};
var template = { data: { label: 'new node' } };
copiableProperties(template, {
label: {
get() {return this.data.label; },
set(value) { this.data.label = value; },
},
});
var test = angular.copy(template);
test.label = 'not working';
output.textContent = test.data.label;