/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * PageStyleFront, the front object for the PageStyleActor
*/ class PageStyleFront extends FrontClassWithSpec(pageStyleSpec) {
_attributesCache = new Map();
/** * Get an array of existing attribute values in a node document, given an attribute type. * * @param {String} search: A string to filter attribute value on. * @param {String} attributeType: The type of attribute we want to retrieve the values. * @param {Element} node: The element we want to get possible attributes for. This will * be used to get the document where the search is happening. * @returns {Array<String>} An array of strings
*/
async getAttributesInOwnerDocument(search, attributeType, node) { if (!attributeType) { thrownew Error("`type` should not be empty");
}
if (!search) { return [];
}
const lcFilter = search.toLowerCase();
// If the new filter includes the string that was used on our last trip to the server, // we can filter the cached results instead of calling the server again. if ( this._attributesCache && this._attributesCache.has(attributeType) &&
search.startsWith(this._attributesCache.get(attributeType).search)
) { const cachedResults = this._attributesCache
.get(attributeType)
.results.filter(item => item.toLowerCase().startsWith(lcFilter)); this.emitForTests( "getAttributesInOwnerDocument-cache-hit",
cachedResults
); return cachedResults;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.