208be8dfbf
* This commit implements the following main changes: - Query elements by using a TreeWalker instead of `document.querySelector[All]`. The reason for this is that `querySelector[All]` doesn't traverse into elements with ShadowRoot. - Recursively traverse into elements with `openOrClosedShadowRoot` or `Element.shadowRoot` (depending on browser support) inside TreeWalker loop. - Use new query logic everywhere inside `autofill.js`. This also means we need to use filter functions to find elements with specific nodeNames and/or attributes instead of CSS selector strings. - Add two new `instanceof Element` checks to prevent `Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'." errors`. This change is fully backward compatible. If `openOrClosedShadowRoot` is not available it will always return undefined and we will never traverse into ShadowRoots just as the behavior was before this change. * refactor: outsource recursive logic to accumulatingQueryDocAll We don't want the `els` argument on the `queryDocAll` function because it's never used from outside the function itself. Thus the recursive logic is moved to `accumulatingQueryDocAll`. Now `queryDocAll` creates an empty array and passes it to `accumulatingQueryDocAll` which recursively walks the document and all ShadowRoots and pushes all found nodes directly to the referenced array. The decision to use a directly mutated array instead of `Array.concat(els)` or `Array.push(...els)` is for performance reasons. Pushing to the referenced array was 74% faster than using `Array.push` with spread operator and even 90% faster than using `Array.concat`. Co-authored-by: Chad Miller <64046472+chadm-sq@users.noreply.github.com> * refactor: extract input field relevance check into own function Addresses CodeScene analysis violation "Bumpy Road Ahead" where conditional logic is checked for a nesting of 2 or deeper. * refactor: use proper element attribute handling - use el.type attribute instead of el.attribute.type on input elements. This makes sure we also get 'text' when type attribute is not explicitly specified - use el.htmlFor attribute instead of el.attribute.for on label elements - use `hasAttribute` and `getAttribute` methods instead of `attributes[]` which is discouraged by https://quirksmode.org/dom/core/#attributes - improve readability of `isRelevantInputField` --------- Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Co-authored-by: Chad Miller <64046472+chadm-sq@users.noreply.github.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com> |
||
---|---|---|
.. | ||
.vscode | ||
config | ||
src | ||
store | ||
.gitignore | ||
README.md | ||
crowdin.yml | ||
gulpfile.js | ||
jest.config.js | ||
package.json | ||
test.setup.ts | ||
tsconfig.json | ||
tsconfig.spec.json | ||
webpack.config.js |
README.md
Bitwarden Browser Extension
The Bitwarden browser extension is written using the Web Extension API and Angular.
Documentation
Please refer to the Browser section of the Contributing Documentation for build instructions, recommended tooling, code style tips, and lots of other great information to get you started.