UNPKG

2.26 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
5 * This code may only be used under the BSD style license found at
6 * http://polymer.github.io/LICENSE.txt
7 * The complete set of authors may be found at
8 * http://polymer.github.io/AUTHORS.txt
9 * The complete set of contributors may be found at
10 * http://polymer.github.io/CONTRIBUTORS.txt
11 * Code distributed by Google as part of the polymer project is also
12 * subject to an additional IP rights grant found at
13 * http://polymer.github.io/PATENTS.txt
14 */
15var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16 return new (P || (P = Promise))(function (resolve, reject) {
17 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
20 step((generator = generator.apply(thisArg, _arguments || [])).next());
21 });
22};
23Object.defineProperty(exports, "__esModule", { value: true });
24const dom5 = require("dom5/lib/index-next");
25const model_1 = require("../model/model");
26const p = dom5.predicates;
27const isCssImportNode = p.AND(p.hasTagName('link'), p.hasSpaceSeparatedAttrValue('rel', 'import'), p.hasAttr('href'), p.hasAttrValue('type', 'css'), p.parentMatches(p.hasTagName('dom-module')));
28class CssImportScanner {
29 scan(document, visit) {
30 return __awaiter(this, void 0, void 0, function* () {
31 const imports = [];
32 yield visit((node) => {
33 if (isCssImportNode(node)) {
34 const href = dom5.getAttribute(node, 'href');
35 imports.push(new model_1.ScannedImport('css-import', href, document.sourceRangeForNode(node), document.sourceRangeForAttributeValue(node, 'href'), { language: 'html', node, containingDocument: document }, false));
36 }
37 });
38 return { features: imports, warnings: [] };
39 });
40 }
41}
42exports.CssImportScanner = CssImportScanner;
43//# sourceMappingURL=css-import-scanner.js.map
\No newline at end of file