simplajs / simpla

Open, modular, and serverless content management for a modern web
https://www.simplajs.org
MIT License
527 stars 36 forks source link

Fix leaking references to internal state #69

Closed bedeoverend closed 7 years ago

bedeoverend commented 7 years ago

Currently get / find / observer methods are sometimes returning references to the internal state, which means changes to these objects will affect Simpla's internal state e.g.

Simpla.get('/image')
  .then(item => {
    item.data.alt = 'Some image'
  })
  .then(() => Simpla.get('/image'))
  .then(item => {
    // item.data.alt === 'Some Image'
  });

This PR patches this by ensuring all data returned is a deep clone of the state's data.