source: trip-planner-front/node_modules/@angular/cdk/schematics/utils/parse5-element.mjs

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.5 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.getChildElementIndentation = void 0;
11const schematics_1 = require("@angular-devkit/schematics");
12/** Determines the indentation of child elements for the given Parse5 element. */
13function getChildElementIndentation(element) {
14 const childElement = element.childNodes
15 .find(node => node.tagName);
16 if ((childElement && !childElement.sourceCodeLocation) || !element.sourceCodeLocation) {
17 throw new schematics_1.SchematicsException('Cannot determine child element indentation because the ' +
18 'specified Parse5 element does not have any source code location metadata.');
19 }
20 const startColumns = childElement ?
21 // In case there are child elements inside of the element, we assume that their
22 // indentation is also applicable for other child elements.
23 childElement.sourceCodeLocation.startCol :
24 // In case there is no child element, we just assume that child elements should be indented
25 // by two spaces.
26 element.sourceCodeLocation.startCol + 2;
27 // Since Parse5 does not set the `startCol` properties as zero-based, we need to subtract
28 // one column in order to have a proper zero-based offset for the indentation.
29 return startColumns - 1;
30}
31exports.getChildElementIndentation = getChildElementIndentation;
32//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2U1LWVsZW1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3NjaGVtYXRpY3MvdXRpbHMvcGFyc2U1LWVsZW1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7O0FBRUgsMkRBQStEO0FBRy9ELGlGQUFpRjtBQUNqRixTQUFnQiwwQkFBMEIsQ0FBQyxPQUFnQjtJQUN6RCxNQUFNLFlBQVksR0FBRyxPQU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