Skip to content

Commit

Permalink
Update to 4.0.0-rc.3
Browse files Browse the repository at this point in the history
  • Loading branch information
terrylinooo committed Dec 2, 2023
1 parent 42aed15 commit 11cbecb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,35 @@ new Disableautofill('#testForm', {

## Development

### `npm run dev`
#### `npm run dev`

Starts a Vite server with hot reload.

### `npm run lint`
![](https://i.imgur.com/OeZhi6a.png)

This page is the entry point of the development server. You can find it at `http://localhost:9527/`.

#### `npm run lint`

Executes linting by ESLint.

### `npm run test`
#### `npm run test`

Runs tests by Vitest.

### `npm run coverage`
#### `npm run coverage`

Runs coverage analysis by Vitest. Once you run this command, you can find the coverage report in the `coverage` directory.
```
http://localhost:9527/coverage/
```

You will see the coverage report like this:

![](https://i.imgur.com/4vQxiB0.png)



### Using Docker

If Docker is your preferred choice, here's what you need to know.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "disableautofill",
"version": "4.0.0-rc.2",
"version": "4.0.0-rc.3",
"description": "The easiest solution for disabling Google Chrome auto-fill, auto-complete functions.",
"main": "dist/disableautofill.umd.js",
"module": "dist/disableautofill.es.js",
Expand Down
8 changes: 6 additions & 2 deletions src/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ export default class Main {
event: EventAdapter | null;
state: State;

constructor(formSelector: string, options: Partial<Config>) {
constructor(form: string | HTMLFormElement, options: Partial<Config>) {
if (form instanceof HTMLFormElement) {
this.form = form;
} else {
this.form = document.querySelector(form) as HTMLFormElement;
}
this.setting = { ...config, ...options };
this.form = document.querySelector(formSelector) as HTMLFormElement;
this.clonedForm = this.form?.cloneNode(true) as HTMLFormElement;
this.event = null;
this.state = new State();
Expand Down
6 changes: 6 additions & 0 deletions tests/units/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ describe('Main class', () => {
expect(main.form).not.toBeNull();
});

test('should initialize with Form element', () => {
const form = document.querySelector('#login-form');
const main = new Main(form, {});
expect(main.form).not.toBeNull();
});

test('should handle invalid form selector', () => {
const originalConsoleError = console.error;
console.error = vi.fn();
Expand Down

0 comments on commit 11cbecb

Please sign in to comment.