ttribute 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} An array of strings */ async getAttributesInOwnerDocument(search, attributeType, node) { if (!attributeType) { throw new 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; } const results = await super.getAttributesInOwnerDocument( search, attributeType, node ); this._attributesCache.set(attributeType, { search, results }); return results; } _clearAttributesCache() { this._attributesCache.clear(); } } registerFront(PageStyleFront); PK