Skip to content

Commit

Permalink
feat(configure): Deprecate branding: Object, use a string instead. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers authored Nov 12, 2021
1 parent dfa9725 commit 1f01309
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
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

0 comments on commit 1f01309

Please sign in to comment.