0

I have upgraded to the latest breeze version and now in`

 function movePropsToBackingStore(instance) {

    var bs = getBackingStore(instance);
    var proto = Object.getPrototypeOf(instance);
    var stype = proto.entityType || proto.complexType;
    stype.getProperties().forEach(function(prop) {
        var propName = prop.name;
        if (!instance.hasOwnProperty(propName)) return;
        // pulls off the value, removes the instance property and then rewrites it via ES5 accessor
        var value = instance[propName];
        delete instance[propName];
        instance[propName] = value;
    });
    return bs;
}

i am getting exceptions in which - cannot delete properties in strict mode!!! for some of my entities i have registered CTORS with computed properties

is there a work around or is it a bug?

example of ctor

define(['sharedServices/dataRepository', 'sharedServices/enumRepository'], function (dataRepository, enumRepository) {
'use strict';

return function () {
    this.segments = undefined;
    var that = this;

    function isArray(value) {
        return value &&
            typeof value === 'object' &&
            typeof value.length === 'number' &&
            typeof value.splice === 'function' &&
            !(value.propertyIsEnumerable('length'));
    }

    function handlePropertySet(entityName, newState) {
        if ((isArray(newState) && newState.length === 0) || (!isArray(newState) && !newState.results)) {
            return;
        }
        var i = 0,
            value = isArray(newState) ? newState : newState.results;

        for (i; i < value.length; i++) {
            dataRepository.addUnchangedEntity(entityName, value[i]);
        }
    }

    function handlePropertyGet(enstate, ename) {
        if (that[enstate] === undefined || that[enstate] === null) {
            if (!that.entityAspect || !that.entityAspect.entityManager || !that.entityAspect.entityManager.isReady) {
                that[enstate] = null;
            } else {
                that[enstate] = that.entityAspect.entityManager.executeQueryLocally(new breeze.EntityQuery(ename).
                    where('VirtualTourID', 'eq', that.ID));
            }

        }

        return that[enstate] === null ? [] : that[enstate];
    }

    Object.defineProperty(this, 'Segments', {
        get: function () {
            return handlePropertyGet('segments', "VirtualTourSegments");
        },
        set: function (value) { //used only when loading tours from the server
            handlePropertySet('CVirtualTourSegment', value);
        },
        enumerable: true
    });

};

});

i get error when deleting Segments also I am using IE11

li-raz
  • 1,678
  • 2
  • 29
  • 57

1 Answers1

0

I can't repro your issue. Can you post an example of a ctor with a property that cannot be deleted?

In general, strict mode does not actually disallow deleting instances of properties. However, see: Why is delete not allowed in Javascript5 strict mode?

Community
  • 1
  • 1
Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • added to the main post – li-raz Jun 04 '14 at 17:52
  • If in the Ctor I will use Intilizer which is the post creation - will it help? – li-raz Jun 04 '14 at 18:03
  • adding configurable:true to the properties - fix it – li-raz Jun 05 '14 at 13:00
  • ok, that makes sense, I think. I'll try to get something into the Breeze documentation to state that you must make any ES5 properties defined in the ctor configurable. and thx for finding this. – Jay Traband Jun 05 '14 at 17:48
  • I updated the ["Extending Entities" topic](http://www.breezejs.com/documentation/extending-entities#es5-property) to clarify this point. – Ward Jun 06 '14 at 02:02