Skip to content

Commit

Permalink
do not create global (instance level) refs for IDs that start from #
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Jun 23, 2015
1 parent 0ccf7e7 commit e7b0ee7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/ajv.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ function Ajv(opts) {

resolve.ids.call(self, schema);

var validate = self._refs[id] = compileSchema.call(self, schema);
var validate = compileSchema.call(self, schema);
if (id[0] != '#') self._refs[id] = validate;
self._cache.put(str, validate);

return validate;
Expand Down
5 changes: 3 additions & 2 deletions lib/compile/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ function resolve(compile, root, ref) {
var currentRoot = util.copy(root);
var schema = _resolve.call(this, root, ref);
var v;
if (typeof schema == 'function') v = this._refs[ref] = schema;
else if (schema) v = this._refs[ref] = compile.call(this, schema, root);
if (typeof schema == 'function') v = schema;
else if (schema) v = compile.call(this, schema, root);
if (v && ref[0] != '#') this._refs[ref] = v;
util.copy(currentRoot, root);
return v;
};
Expand Down

0 comments on commit e7b0ee7

Please sign in to comment.