Skip to content
This repository
Browse code

fixed; setting invalid paths in strict mode

closes #916
  • Loading branch information...
commit 22550755a3a6643916ae5e13361d8a79fa9cf227 1 parent e6f7852
Aaron Heckmann aheckmann authored

Showing 2 changed files with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. +3 1 lib/document.js
  2. +2 0  test/document.strict.test.js
4 lib/document.js
@@ -362,7 +362,9 @@ Document.prototype.set = function (path, val, type) {
362 362 }
363 363
364 364 var schema;
365   - if ('virtual' === pathType) {
  365 + if ('adhocOrUndefined' == pathType && this._strictMode) {
  366 + return this;
  367 + } else if ('virtual' == pathType) {
366 368 schema = this.schema.virtualpath(path);
367 369 schema.applySetters(val, this);
368 370 return this;
2  test/document.strict.test.js
@@ -119,10 +119,12 @@ module.exports = {
119 119
120 120 s = new Strict;
121 121 s.set('name', { last: 'goose', hack: 'xx' });
  122 + s.set('shouldnt.exist', ':(');
122 123 s = s.toObject();
123 124 s.name.last.should.equal('goose');
124 125 s.name.should.not.have.property('hack');
125 126 should.not.exist(s.name.hack);
  127 + should.not.exist(s.shouldnt);
126 128 },
127 129
128 130 'sub doc strict mode': function(){

0 comments on commit 2255075

Please sign in to comment.
Something went wrong with that request. Please try again.