ContentEdit
ContentEdit copied to clipboard
new ContentEdit.Region is always tainted
Hi,
I am not sure if it's a bug or not but I have to call region.commit() after each new region.
var region = new ContentEdit.Region( item );
// the following line is needed otherwise region.lastModified() will not be null
region.commit();
console.log(region.lastModified());
Geza
Hi @turigeza - I think this is a probably a bug and it's certainly not intuitive.
On creating a region (and it's children) the last modified date for the region is set at the time that you created it. What the ContentTools editor does is store the lastModified
time for each region after initialising them and that is these are then compared to determine on save if the last modified time has changed for each region (https://github.com/GetmeUK/ContentTools/blob/master/src/scripts/editor.coffee#L838).
I think that on creating a new region once setContent
is called we can safely call commit and nullify the last modified date against the region and all it's children. I'll try this out and see if there are any hidden side effects I'm not accounting for but in principle I agree this should be changed.