|
1 | 1 | import { createNewLookupObject } from './create-new-lookup-object';
|
2 | 2 | import * as logger from '../logger';
|
3 | 3 |
|
| 4 | +const loggedProperties = Object.create(null); |
| 5 | + |
4 | 6 | export function createProtoAccessControl(runtimeOptions) {
|
5 | 7 | let defaultMethodWhiteList = Object.create(null);
|
6 | 8 | defaultMethodWhiteList['constructor'] = false;
|
@@ -45,12 +47,24 @@ function checkWhiteList(protoAccessControlForType, propertyName) {
|
45 | 47 | if (protoAccessControlForType.defaultValue !== undefined) {
|
46 | 48 | return protoAccessControlForType.defaultValue;
|
47 | 49 | }
|
48 |
| - // eslint-disable-next-line no-console |
49 |
| - logger.log( |
50 |
| - 'error', |
51 |
| - `Handlebars: Access has been denied to resolve the property "${propertyName}" because it is not an "own property" of its parent.\n` + |
52 |
| - `You can add a runtime option to disable the check or this warning:\n` + |
53 |
| - `See http://localhost:8080/api-reference/runtime-options.html#options-to-control-prototype-access for details` |
54 |
| - ); |
| 50 | + logUnexpecedPropertyAccessOnce(propertyName); |
55 | 51 | return false;
|
56 | 52 | }
|
| 53 | + |
| 54 | +function logUnexpecedPropertyAccessOnce(propertyName) { |
| 55 | + if (loggedProperties[propertyName] !== true) { |
| 56 | + loggedProperties[propertyName] = true; |
| 57 | + logger.log( |
| 58 | + 'error', |
| 59 | + `Handlebars: Access has been denied to resolve the property "${propertyName}" because it is not an "own property" of its parent.\n` + |
| 60 | + `You can add a runtime option to disable the check or this warning:\n` + |
| 61 | + `See http://localhost:8080/api-reference/runtime-options.html#options-to-control-prototype-access for details` |
| 62 | + ); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +export function resetLoggedProperties() { |
| 67 | + Object.keys(loggedProperties).forEach(propertyName => { |
| 68 | + delete loggedProperties[propertyName]; |
| 69 | + }); |
| 70 | +} |
0 commit comments