UNPKG

flagpole

Version:

Simple and fast DOM integration, headless or headful browser, and REST API testing framework.

54 lines 2.21 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const value_1 = require("./value"); class CSSRule extends value_1.Value { constructor(input, context, name, path) { super(input, context, name); this._path = path || ""; } get path() { return this._path; } get name() { return this._name || this._path || "CSS Rule"; } static create(input, context, name, path) { return new CSSRule(input, context, name, path); } hasProperty(key) { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue((yield this.getProperty(key)) !== null, `${this.name} has property ${key}`); }); } getProperty(key) { return __awaiter(this, void 0, void 0, function* () { const declarations = this._getDeclarations(); let value = null; declarations.some((declaration) => { if (declaration.property == key) { value = declaration.value; return true; } return false; }); return new value_1.Value(value, this._context, `CSS Value of ${key} for ${this._path}`); }); } _getSelectors() { return this._input.selectors ? this._input.selectors : []; } _getDeclarations() { return this._input.declarations ? this._input.declarations : []; } } exports.CSSRule = CSSRule; //# sourceMappingURL=cssrule.js.map