Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(configure): Deprecate branding: Object, use a string instead. #3278

Merged
merged 1 commit into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ declare namespace axe {
cssColors?: { [key: string]: number[] };
}
interface Spec {
branding?: {
brand?: string;
application?: string;
};
branding?: string | Branding;
reporter?: ReporterVersion;
checks?: Check[];
rules?: Rule[];
Expand All @@ -203,6 +200,13 @@ declare namespace axe {
// Deprecated - do not use.
ver?: string;
}
/**
* @deprecated Use branding: string instead to set the application key in help URLs
*/
interface Branding {
brand?: string;
application?: string;
}
interface Check {
id: string;
evaluate?: Function | string;
Expand Down
7 changes: 3 additions & 4 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ User specifies the format of the JSON structure passed to the callback of `axe.r

```js
axe.configure({
branding: {
brand: String,
application: String
},
branding: String,
reporter: 'option' | Function,
checks: [Object],
rules: [Object],
Expand Down Expand Up @@ -245,6 +242,8 @@ axe.configure({

**Returns:** Nothing

**Note**: The `branding` property accepts a `string`, which sets the application. Passing it an object is deprecated as of axe-core 4.4.0, as is the `branding.brand` property.

##### Page level rules

Page level rules split their evaluation into two phases. A 'data collection' phase which is done inside the 'evaluate' function and an assessment phase which is done inside the 'after' function. The evaluate function executes inside each individual frame and is responsible for collection data that is passed into the after function which inspects that data and makes a decision.
Expand Down
3 changes: 3 additions & 0 deletions lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ class Audit {
brand: this.brand,
application: this.application
};
if (typeof branding === 'string') {
this.application = branding
}
if (
branding &&
branding.hasOwnProperty('brand') &&
Expand Down
8 changes: 8 additions & 0 deletions test/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ describe('Audit', function() {
assert.equal(audit.brand, 'axe');
assert.equal(audit.application, 'thing');
});
it('should change the application when passed a string', function() {
var audit = new Audit();
assert.equal(audit.brand, 'axe');
assert.equal(audit.application, 'axeAPI');
audit.setBranding('thing');
assert.equal(audit.brand, 'axe');
assert.equal(audit.application, 'thing');
});
it('should call _constructHelpUrls', function() {
var audit = new Audit();
audit.addRule({
Expand Down