Skip to content

Commit

Permalink
fix(ignore-whitespace): Update CSS selectors
Browse files Browse the repository at this point in the history
Fix "Ignore Whitespace" feature that broke after Atlassian migrated
their pull request list page to a CSS-in-JS solution that autogenerates
the CSS class names of the elements, making the previous selectors the
extension relied on useless.

Closes #285
  • Loading branch information
reyronald committed Jun 9, 2019
1 parent 3bb87de commit 64c4f3c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Next Version

### Bug Fixes

- Fix "Ignore Whitespace" feature that broke after Atlassian migrated their pull request list page
to a CSS-in-JS solution that autogenerates the CSS class names of the elements, making the
previous selectors the extension relied on useless,
closes [issue #285](https://github.com/refined-bitbucket/refined-bitbucket/issues/285),
[pull request #290](https://github.com/refined-bitbucket/refined-bitbucket/pull/290).

# 3.17.0 (2019-06-03)

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion src/ignore-whitespace/ignore-whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export default function init(prRow: Element) {
const link: HTMLAnchorElement = (prRow.querySelector(
'a.pull-request-title'
'a[data-qa="pull-request-row-link"]'
): any)
const url = new URL(link.href)
const searchParams = new URLSearchParams(url.search)
Expand Down
6 changes: 3 additions & 3 deletions src/ignore-whitespace/ignore-whitespace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('should transform pull request link to add ignore whitespace query param to
const actual = (
<div>
<a
class="pull-request-title"
data-qa="pull-request-row-link"
title="pull request title"
href="https://bitbucket.org/user/repo/pull-requests/1"
>
Expand All @@ -21,7 +21,7 @@ test('should transform pull request link to add ignore whitespace query param to
const expected = (
<div>
<a
class="pull-request-title"
data-qa="pull-request-row-link"
title="pull request title"
href="https://bitbucket.org/user/repo/pull-requests/1?w=1"
>
Expand All @@ -39,7 +39,7 @@ test('should transform pull request link to toggle ignore whitespace query param
const actual = (
<div>
<a
class="pull-request-title"
data-qa="pull-request-row-link"
title="pull request title"
href="https://bitbucket.org/user/repo/pull-requests/1?w=0"
>
Expand Down
22 changes: 12 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,21 @@ function pullrequestListRelatedFeatures(config) {
return
}

const prTable = document.querySelector('.pull-requests-table')

// eslint-disable-next-line no-new
new SelectorObserver(prTable, 'tr.pull-request-row', function() {
if (config.ignoreWhitespace) {
ignoreWhitespace(this)
}
new SelectorObserver(
document.body,
'tr[data-qa="pull-request-row"]',
function() {
if (config.ignoreWhitespace) {
ignoreWhitespace(this)
}

if (config.augmentPrEntry) {
linkifyTargetBranch(this)
augmentPrEntry(this)
if (config.augmentPrEntry) {
linkifyTargetBranch(this)
augmentPrEntry(this)
}
}
})
)
}

function codeReviewFeatures(config) {
Expand Down

0 comments on commit 64c4f3c

Please sign in to comment.