DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
    • can-define/list/list
    • can-define/map/map
      • events
        • __keys
        • propertyName
      • static
        • extend
        • seal
      • prototype
        • forEach
        • get
        • on
        • serialize
        • set
        • *
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-define/map/map
  • /
  • seal
  • / On this page
    • seal

      property

      Defines if instances of the map should be sealed in development.

      • source

      Boolean

      If true, in development, instances of this object will be sealed. In strict mode errors will be thrown when undefined properties are set. This is the default behavior of extended DefineMaps:

      "use strict";
      var Person = DefineMap.extend({});
      var me = new Person();
      me.age = 33 //-> throws "TypeError: Can't add property age, object is not extensible"
      

      If false, the object will not be sealed. This is the default behavior of unextended DefineMaps. Use get and set to get and set values:

      var person = new DefineMap();
      person.set("first","Justin");
      person.set("last","Meyer");
      
      person.get("first") //-> "Justin"
      person.get("last") //-> "Meyer"
      

      Set seal to false on objects that have an indeterminate number of properties:

      var Style = DefineMap.extend({
        seal: false
      },{
        cssText: {
          get: function(){
            return _.map(this.get(), function(val, prop){
              return prop+": "+val;
            }).join(";")
          }
        }
      });
      var style = new Style();
      style.set("color","green");
      style.set("font","awesome");
      style.cssText //-> "color:green; font: awesome;"
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.