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

Fix: Resolve minor JavaScript linting issues and hasOwnProperty warning (fixes #571) #572

Merged
merged 2 commits into from
Aug 19, 2024
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
2 changes: 1 addition & 1 deletion js/fixes/img.lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function applyImgLoadingFix() {
Adapt.on('reactElement:preRender', event => {
if (event.name !== 'img') return;
const options = event.args[1] = event.args[1] || {};
if (options && options.hasOwnProperty('loading')) return;
if (options && Object.prototype.hasOwnProperty.call(options, 'loading')) return;
oliverfoster marked this conversation as resolved.
Show resolved Hide resolved
options.loading = 'eager';
});
}
4 changes: 2 additions & 2 deletions js/models/itemsComponentModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class ItemsComponentModel extends ComponentModel {
this.setUpItems();
this.listenTo(this.getChildren(), {
all: this.onAll,
'change': this.storeUserAnswer,
change: this.storeUserAnswer,
'change:_isActive': this.setVisitedStatus,
'change:_isVisited': this.checkCompletionStatus
});
Expand All @@ -27,7 +27,7 @@ export default class ItemsComponentModel extends ComponentModel {
this.getChildren().forEach(child => child.set('_isVisited', booleanArray[child.get('_index')]));
}

storeUserAnswer() {
storeUserAnswer() {
const items = this.getChildren().slice(0);
items.sort((a, b) => a.get('_index') - b.get('_index'));
const booleanArray = items.map(child => child.get('_isVisited'));
Expand Down
26 changes: 13 additions & 13 deletions js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,19 @@ class Router extends Backbone.Router {
let _parentId = parentModel.get('_id');
const built = buildTypes.map((_type, index) => {
const ModelClass = components.getModelClass({ _type });
const _id = `preview-${_type}`
const _id = `preview-${_type}`;
const builtModel = new ModelClass({
_type,
_id,
_parentId,
_isPreview: true
});
if (index) parentModel.getChildren().add(builtModel)
data.add(builtModel)
parentModel = builtModel
_parentId = _id
return builtModel
})
if (index) parentModel.getChildren().add(builtModel);
data.add(builtModel);
parentModel = builtModel;
_parentId = _id;
return builtModel;
});
// Clone the requested content to sanitise
model.deepClone((clone, orig) => {
// Make the cloned item available and unlocked
Expand All @@ -298,16 +298,16 @@ class Router extends Backbone.Router {
});
});
built.forEach(model => model.setupModel());
isContentObject = true
model = built[0]
model.setOnChildren({ _isPreview : true })
isContentObject = true;
model = built[0];
model.setOnChildren({ _isPreview: true });
}

const navigateToId = model.get('_id');

// Ensure that the router is rendering a contentobject
model = isContentObject ? model : model.findAncestor('contentobject');
id = model.get('_id');
id = navigateToId;

/**
* TODO:
Expand Down Expand Up @@ -351,7 +351,7 @@ class Router extends Backbone.Router {
}

async removePreviews() {
const previews = data.filter(model => model.get('_isPreview'))
const previews = data.filter(model => model.get('_isPreview'));
previews.forEach(model => data.remove(model));
}

Expand Down Expand Up @@ -582,7 +582,7 @@ class Router extends Backbone.Router {
}

onLanguageChange() {
this.updateLocation(null, null, null, null)
this.updateLocation(null, null, null, null);
}

}
Expand Down
2 changes: 1 addition & 1 deletion js/views/buttonsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default class ButtonsView extends Backbone.View {
: isPartlyCorrect
? (ariaLabels.answeredPartlyCorrect ?? ariaLabels.answeredIncorrectly)
: ariaLabels.answeredIncorrectly;

if (!hasSpanAriaLabel) {
// Backward compability
$marking.attr('aria-label', correctnessAriaLabel);
Expand Down
2 changes: 1 addition & 1 deletion js/views/menuItemView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MenuItemView extends AdaptView {

attributes() {
return AdaptView.resultExtend('attributes', {
'role': 'listitem',
role: 'listitem',
'aria-labelledby': this.model.get('_id') + '-heading'
}, this);
}
Expand Down
Loading