PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0-beta1
Elementor Website Builder – more than just a page builder v3.8.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
elementor / app / modules / kit-library / assets / js / models / base-model.js

base-model.js in Elementor Website Builder – more than just a page builder 3.8.0-beta1, at app/modules/kit-library/assets/js/models/base-model.js

32 lines 627 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 export default class BaseModel {
2 /**
3 * Clone to object to avoid changing the reference.
4 *
5 * @return {BaseModel} cloned model
6 */
7 clone() {
8 const instance = new this.constructor();
9
10 Object.keys( this ).forEach( ( key ) => {
11 instance[ key ] = this[ key ];
12 } );
13
14 return instance;
15 }
16
17 /**
18 * Using init and not the default constructor because there is a problem to fill the instance
19 * dynamically in the constructor.
20 *
21 * @param {*} data
22 * @return {BaseModel} model
23 */
24 init( data = {} ) {
25 Object.entries( data ).forEach( ( [ key, value ] ) => {
26 this[ key ] = value;
27 } );
28
29 return this;
30 }
31 }
32