diff --git a/.github/actions/setup-node-env/action.yml b/.github/actions/setup-node-env/action.yml index e7b07fb..19daedf 100644 --- a/.github/actions/setup-node-env/action.yml +++ b/.github/actions/setup-node-env/action.yml @@ -24,26 +24,7 @@ runs: node_modules key: modules-${{ hashFiles('package-lock.json') }} - - name: Cache Playwright Binaries - id: cache-playwright - uses: actions/cache@v4 - with: - path: | - ~/.cache/ms-playwright - key: playwright-${{ hashFiles('package-lock.json') }} - - name: Install dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true' run: npm ci shell: bash - - - name: Install playwright browsers - if: steps.cache-playwright.outputs.cache-hit != 'true' - run: npx playwright install --with-deps - shell: bash - - - name: Install system dependencies for WebKit - # Some WebKit dependencies seem to lay outside the cache and will need to be installed separately - if: steps.cache-playwright.outputs.cache-hit == 'true' - run: npx playwright install-deps webkit - shell: bash diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e00d47..560a94b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,12 +4,19 @@ on: [push, pull_request, workflow_dispatch] jobs: test: runs-on: ubuntu-latest + steps: + - name: Set CHROME_PATH + run: echo "CHROME_PATH=/ms-playwright/chrome-linux/chrome" >> $GITHUB_ENV + - name: Checkout uses: actions/checkout@v4 - uses: ./.github/actions/setup-node-env + - name: Run ESLint checks + run: npm run-script lint + - name: Build run: npm run-script build diff --git a/editv2.spec.ts b/editv2.spec.ts index 0cdf5af..d1f0c27 100644 --- a/editv2.spec.ts +++ b/editv2.spec.ts @@ -14,7 +14,12 @@ const element = new DOMParser().parseFromString( 'application/xml', )!.documentElement; -const update: Update = { element, attributes: {} }; +const update: Update = { + element, + attributes: { + attr1: { namespaceURI: 'http://myns.com', value: 'new value' }, + }, +}; const insert: Insert = { parent: element, node: element, reference: null }; const remove: Remove = { node: element }; const setAttributes: SetAttributes = { diff --git a/editv2.ts b/editv2.ts index a2b10d0..1d48223 100644 --- a/editv2.ts +++ b/editv2.ts @@ -81,10 +81,11 @@ export function isRemove(edit: unknown): edit is Remove { } export function isSetAttributes(edit: unknown): edit is SetAttributes { + const setAttrs = edit as SetAttributes; return ( - (edit as SetAttributes).element instanceof Element && - isAttributesV2((edit as SetAttributes).attributes) && - isAttributesNS((edit as SetAttributes).attributesNS) + setAttrs.element instanceof Element && + (isAttributesV2(setAttrs.attributes) || + isAttributesNS(setAttrs.attributesNS)) ); } diff --git a/package.json b/package.json index 5864989..993de67 100644 --- a/package.json +++ b/package.json @@ -82,9 +82,9 @@ }, "lint-staged": { "*.ts": [ - "eslint --fix --config package.json", + "eslint --fix", "prettier --write", - "eslint --config package.json" + "eslint" ] } }