本文整理汇总了TypeScript中angular2/src/facade/lang.assertionsEnabled函数的典型用法代码示例。如果您正苦于以下问题:TypeScript assertionsEnabled函数的具体用法?TypeScript assertionsEnabled怎么用?TypeScript assertionsEnabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertionsEnabled函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(config?: ChangeDetectorGenConfig,
protoChangeDetectorsForTest?: StringMap<string, Function>) {
super();
this._dynamicChangeDetection = new DynamicChangeDetection();
this._protoChangeDetectorFactories = isPresent(protoChangeDetectorsForTest) ?
protoChangeDetectorsForTest :
preGeneratedProtoDetectors;
this._genConfig =
isPresent(config) ? config : new ChangeDetectorGenConfig(assertionsEnabled(),
assertionsEnabled(), false);
}
示例2: xdescribe
xdescribe('Missing directive checks', () => {
if (assertionsEnabled()) {
function expectCompileError(inlineTpl, errMessage, done) {
tplResolver.setTemplate(MyComp, new Template({inline: inlineTpl}));
PromiseWrapper.then(compiler.compile(MyComp), (value) => {
throw new BaseException("Test failure: should not have come here as an exception was expected");
}, (err) => {
expect(err.message).toEqual(errMessage);
done();
});
}
it('should raise an error if no directive is registered for a template with template bindings', inject([AsyncTestCompleter], (async) => {
expectCompileError('<div><div template="if: foo"></div></div>', 'Missing directive to handle \'if\' in <div template="if: foo">', () => async.done());
}));
it('should raise an error for missing template directive (1)', inject([AsyncTestCompleter], (async) => {
expectCompileError('<div><template foo></template></div>', 'Missing directive to handle: <template foo>', () => async.done());
}));
it('should raise an error for missing template directive (2)', inject([AsyncTestCompleter], (async) => {
expectCompileError('<div><template *if="condition"></template></div>', 'Missing directive to handle: <template *if="condition">', () => async.done());
}));
it('should raise an error for missing template directive (3)', inject([AsyncTestCompleter], (async) => {
expectCompileError('<div *if="condition"></div>', 'Missing directive to handle \'if\' in MyComp: <div *if="condition">', () => async.done());
}));
}
});
示例3: _genThrowOnChangeCheck
/** @internal */
_genThrowOnChangeCheck(oldValue: string, newValue: string): string {
if (assertionsEnabled()) {
return `
if(throwOnChange) {
this.throwOnChangeError(${oldValue}, ${newValue});
}
`;
} else {
return '';
}
}
示例4: _genThrowOnChangeCheck
/** @internal */
_genThrowOnChangeCheck(oldValue: string, newValue: string): string {
if (assertionsEnabled()) {
return `
if (throwOnChange && !${this.changeDetectionUtilVarName}.devModeEqual(${oldValue}, ${newValue})) {
this.throwOnChangeError(${oldValue}, ${newValue});
}
`;
} else {
return '';
}
}
示例5: _createVmZone
function _createVmZone(givenReporter) {
var defaultErrorReporter = (exception, stackTrace) => {
var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n");
print(`${exception}\n\n${longStackTrace}`);
throw exception;
};
var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter;
var zone = new VmTurnZone({enableLongStackTrace: assertionsEnabled()});
zone.initCallbacks({onErrorHandler: reporter});
return zone;
}
示例6: _processContentElement
_processContentElement(current) {
if (this._shadowDomStrategy.hasNativeContentElement()) {
return ;
}
var attrs = current.attrs();
var selector = MapWrapper.get(attrs, 'select');
selector = isPresent(selector) ? selector : '';
var contentStart = DOM.createScriptTag('type', 'ng/contentStart');
if (assertionsEnabled()) {
DOM.setAttribute(contentStart, 'select', selector);
}
var contentEnd = DOM.createScriptTag('type', 'ng/contentEnd');
DOM.insertBefore(current.element, contentStart);
DOM.insertBefore(current.element, contentEnd);
DOM.remove(current.element);
current.element = contentStart;
current.bindElement().setContentTagSelector(selector);
}
示例7: constructor
constructor(element, compilationUnit = '') {
this.element = element;
this._attrs = null;
this._classList = null;
this.isViewRoot = false;
this.inheritedProtoView = null;
this.inheritedElementBinder = null;
this.distanceToInheritedBinder = 0;
this.compileChildren = true;
this.ignoreBindings = false;
var tplDesc = assertionsEnabled() ? getElementDescription(element) : null;
if (compilationUnit !== '') {
this.elementDescription = compilationUnit;
if (isPresent(tplDesc))
this.elementDescription += ": " + tplDesc;
} else {
this.elementDescription = tplDesc;
}
}
示例8: _processContentElement
_processContentElement(current: CompileElement) {
if (this._shadowDomStrategy.hasNativeContentElement()) {
return;
}
var attrs = current.attrs();
var selector = attrs.get('select');
selector = isPresent(selector) ? selector : '';
// The content tag should be replaced by a pair of marker tags (start & end).
// The end marker creation is delayed to keep the number of elements constant.
// Creating the end marker here would invalidate the parent's textNodeIndices for the subsequent
// text nodes
var contentStart = DOM.createScriptTag('type', 'ng/contentStart');
if (assertionsEnabled()) {
DOM.setAttribute(contentStart, 'select', selector);
}
DOM.insertBefore(current.element, contentStart);
DOM.remove(current.element);
current.element = contentStart;
current.bindElement().setContentTagSelector(selector);
}
示例9: compilerProviders
export function compilerProviders(): Array<Type | Provider | any[]> {
return [
Lexer,
Parser,
HtmlParser,
TemplateParser,
TemplateNormalizer,
RuntimeMetadataResolver,
StyleCompiler,
CommandCompiler,
ChangeDetectionCompiler,
provide(ChangeDetectorGenConfig,
{useValue: new ChangeDetectorGenConfig(assertionsEnabled(), false, true)}),
TemplateCompiler,
provide(RuntimeCompiler, {useClass: RuntimeCompiler_}),
provide(Compiler, {useExisting: RuntimeCompiler}),
DomElementSchemaRegistry,
provide(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
AnchorBasedAppRootUrl,
provide(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
UrlResolver
];
}
示例10: createNgZone
export function createNgZone(): NgZone {
return new NgZone({enableLongStackTrace: assertionsEnabled()});
}