Replace .attr('value') with .prop('value')

This is part of fixing tests failures when removing
jquery-migrate 1.4. The fix here is similar to g/341290 where
we need to replace .attr with .prop

refs FOO-4260
flag=none

Test Plan:
- Jenkins passes

[skip-crystalball]

Change-Id: Iee78068598cabdd6f603d4b04c019f31c74fbc87
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/341374
Reviewed-by: Michael Hulse <michael.hulse@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Angela Gomba <angela.gomba@instructure.com>
Product-Review: Angela Gomba <angela.gomba@instructure.com>
This commit is contained in:
Angela Gomba 2024-02-26 16:00:41 -05:00
parent 0ede9a4c9a
commit 2778d31681
7 changed files with 33 additions and 33 deletions

View File

@ -35,7 +35,7 @@ $(function () {
const criteria = []
$alert.find('ul.criteria li').each(function () {
criteria.push({
id: $(this).find('input[name="alert[criteria][][id]"]').attr('value'),
id: $(this).find('input[name="alert[criteria][][id]"]').prop('value'),
criterion_type: $(this).data('value'),
threshold: $(this).find('span').text(),
})
@ -44,9 +44,9 @@ $(function () {
$alert.find('ul.recipients li').each(function () {
recipients.push($(this).data('value'))
})
let repetition = $alert.find('input[name="repetition"]:checked').attr('value')
let repetition = $alert.find('input[name="repetition"]:checked').prop('value')
if (repetition === 'value') {
repetition = $alert.find('input[name="alert[repetition]"]').attr('value')
repetition = $alert.find('input[name="alert[repetition]"]').prop('value')
} else {
repetition = null
}
@ -73,7 +73,7 @@ $(function () {
$element.append(' ')
$element.append($list.find('>.delete_item_link').clone().toggle())
} else {
$element.attr('value', key)
$element.prop('value', key)
}
return $element
}
@ -83,7 +83,7 @@ $(function () {
const $element = createElement(recipient, element, 'label', ENV.ALERTS.POSSIBLE_RECIPIENTS)
if (element === 'li') {
$element.prepend(
$("<input type='hidden' name='alert[recipients][]' />").attr('value', recipient)
$("<input type='hidden' name='alert[recipients][]' />").prop('value', recipient)
)
}
return $element
@ -111,7 +111,7 @@ $(function () {
$element.find('span').text(threshold)
$element
.find('input')
.attr('value', threshold)
.prop('value', threshold)
.attr('title', ENV.ALERTS.POSSIBLE_CRITERIA[criterion_type].title)
$element.prepend(
$("<input type='hidden' name='alert[criteria][][criterion_type]' />").attr(
@ -121,7 +121,7 @@ $(function () {
)
if (id) {
$element.prepend(
$("<input type='hidden' name='alert[criteria][][id]' />").attr('value', id)
$("<input type='hidden' name='alert[criteria][][id]' />").prop('value', id)
)
}
}
@ -143,7 +143,7 @@ $(function () {
}
if (data.repetition) {
$alert.find('input[name="repetition"][value="value"]').prop('checked', true)
$alert.find('input[name="alert[repetition]"]').attr('value', data.repetition)
$alert.find('input[name="alert[repetition]"]').prop('value', data.repetition)
$alert.find('.repetition_group .no_repetition').toggle(false)
$alert.find('.repetition_group .repetition').toggle(true).find('span').text(data.repetition)
} else {
@ -229,7 +229,7 @@ $(function () {
.delegate('.delete_link', 'click', function () {
const $alert = $(this).parents('.alert')
if (!$alert.hasClass('new')) {
$alert.find('input[name="_method"]').attr('value', 'DELETE')
$alert.find('input[name="_method"]').prop('value', 'DELETE')
$.ajaxJSON($alert.attr('action'), 'POST', $alert.serialize(), _data => {
$alert.slideUp(() => {
$alert.remove()
@ -280,7 +280,7 @@ $(function () {
])
}
$alert.find('.criteria input.editing').each(function () {
const val = $(this).attr('value')
const val = $(this).prop('value')
if (!val || Number.isNaN(Number(val)) || parseFloat(val) < 0) {
errors.push([
$(this),
@ -294,11 +294,11 @@ $(function () {
I18n.t('errors.recipients_required', 'At least one recipient is required'),
])
}
if ($alert.find('input[name="repetition"]:checked').attr('value') === 'none') {
$alert.find('input[name="alert[repetition]"]').attr('value', '')
if ($alert.find('input[name="repetition"]:checked').prop('value') === 'none') {
$alert.find('input[name="alert[repetition]"]').prop('value', '')
} else {
const $repetition = $alert.find('input[name="alert[repetition]"]')
const val = $repetition.attr('value')
const val = $repetition.prop('value')
if (!val || Number.isNaN(Number(val)) || parseFloat(val) < 0) {
errors.push([
$repetition,
@ -348,7 +348,7 @@ $(function () {
.delegate('.add_recipient_link', 'click', function () {
const $recipients = $(this).parents('.alert').find('.recipients')
const $select = $(this).prev()
const recipient = $select.attr('value')
const recipient = $select.prop('value')
addRecipientInOrder($recipients, createRecipient(recipient, 'li')).toggle().slideDown()
const $errorBox = $select.data('associated_error_box')
if ($errorBox) {
@ -380,7 +380,7 @@ $(function () {
.delegate('.add_criterion_link', 'click', function () {
const $criteria = $(this).parents('.alert').find('.criteria')
const $select = $(this).prev()
const criterion = $select.attr('value')
const criterion = $select.prop('value')
addRecipientInOrder($criteria, createCriterion(criterion, 'li')).toggle().slideDown()
const $errorBox = $select.data('associated_error_box')
if ($errorBox) {

View File

@ -445,7 +445,7 @@ $(document).ready(function () {
beforeSubmit(data) {
// If Restrict Quantitative Data is checked, then the course must have a default grading scheme selected
const rqdEnabled =
$course_form.find('#course_restrict_quantitative_data')?.attr('value') === 'true'
$course_form.find('#course_restrict_quantitative_data')?.prop('value') === 'true'
const hasCourseDefaultGradingScheme = !!$course_form
.find('.grading_standard_checkbox')
.prop('checked')

View File

@ -94,7 +94,7 @@ $.each(ENV.LDAP_TESTS, (i, test) => {
}
})
function testLDAPLogin() {
$('#ldap_test_login').prop('disabled', true).attr('value', I18n.t('testing', 'Testing...'))
$('#ldap_test_login').prop('disabled', true).prop('value', I18n.t('testing', 'Testing...'))
$('#ldap_login_result').html("<img src='/images/ajax-loader.gif'/>")
const username = $('#ldap_test_login_user').val()
const password = $('#ldap_test_login_pass').val()
@ -123,7 +123,7 @@ function testLDAPLogin() {
)
$('#ldap_test_login')
.prop('disabled', false)
.attr('value', I18n.t('test_login', 'Test Login'))
.prop('value', I18n.t('test_login', 'Test Login'))
} else {
$('#ldap_login_result').html(
"<h4 style='color:red'>" + h(I18n.t('test_ldap_result_failed', 'Failed')) + '</h4>'
@ -131,7 +131,7 @@ function testLDAPLogin() {
$('#ldap_login_help').show()
$('#ldap_test_login')
.prop('disabled', false)
.attr('value', I18n.t('retry_login', 'Retry Login'))
.prop('value', I18n.t('retry_login', 'Retry Login'))
$('#ldap_login_help_error').text(message)
}
}

View File

@ -2428,7 +2428,7 @@ ready(function () {
event.stopPropagation()
const $publish_input = $(document.createElement('input'))
$publish_input.attr('type', 'hidden').attr('name', 'publish').attr('value', 'true')
$publish_input.attr('type', 'hidden').attr('name', 'publish').prop('value', 'true')
$quiz_options_form.append($publish_input)
$quiz_edit_wrapper
@ -4294,7 +4294,7 @@ ready(function () {
buildPlaceMenu(event) {
const option = $(event.target).find('option:selected')
const value = option.length > 0 ? option.attr('value') : 'top'
const value = option.length > 0 ? option.prop('value') : 'top'
// filter by selected
const filtered = this.itemsInGroup(value)
@ -4365,7 +4365,7 @@ ready(function () {
// get selected values
const option = this.$form.find('#move_select_group option:selected')
const group = option.length > 0 ? option.attr('value') : 'top'
const group = option.length > 0 ? option.prop('value') : 'top'
this.reorderDom(group)
this.ajaxPostReorder(group)
@ -4376,7 +4376,7 @@ ready(function () {
reorderDom(group) {
const option = this.$form.find('#move_select_question option:selected')
const place = option.attr('value')
const place = option.prop('value')
const bottom = this.selected.sortable.nextAll('.group_bottom').first()
// move to bottom of the group
@ -4460,7 +4460,7 @@ ready(function () {
buildGroupParams(group) {
const option = this.$form.find('#move_select_question option:selected')
const place = option.attr('value')
const place = option.prop('value')
// rebuild the group list adding in our selection
const selected = this.selected

View File

@ -45,7 +45,7 @@ $(() => {
})
$('input:radio[name="pseudonym_select"]').change(() =>
$merge_link.attr('href', $('input:radio[name="pseudonym_select"]:checked').attr('value'))
$merge_link.attr('href', $('input:radio[name="pseudonym_select"]:checked').prop('value'))
)
const $where_to_log_in = $('#where_to_log_in')

View File

@ -402,7 +402,7 @@ $.ajaxJSONFiles = function (url, submit_type, formData, files, success, error, o
for (const idx in formData) {
if (!fileNames[idx]) {
const $input = $(document.createElement('input'))
$input.attr('type', 'hidden').attr('name', idx).attr('value', formData[idx])
$input.attr('type', 'hidden').attr('name', idx).prop('value', formData[idx])
$newForm.append($input)
}
}

View File

@ -25,22 +25,22 @@ $(function () {
// so find the name by starting with the short_name
const $name = $short_name.parents('form').find('input[name="user[name]"]')
const $sortable_name = $('input[name="user[sortable_name]"]')
let prior_name = $name.attr('value')
let prior_name = $name.prop('value')
$name.keyup(function () {
const name = $name.attr('value')
const sortable_name = $sortable_name.attr('value')
const name = $name.prop('value')
const sortable_name = $sortable_name.prop('value')
const sortable_name_parts = nameParts(sortable_name)
if (
$.trim(sortable_name) === '' ||
firstNameFirst(sortable_name_parts) === $.trim(prior_name)
) {
const parts = nameParts(name, sortable_name_parts[1])
$sortable_name.attr('value', lastNameFirst(parts))
$sortable_name.prop('value', lastNameFirst(parts))
}
const short_name = $short_name.attr('value')
const short_name = $short_name.prop('value')
if ($.trim(short_name) === '' || short_name === prior_name) {
$short_name.attr('value', name)
$short_name.prop('value', name)
}
prior_name = $(this).attr('value')
prior_name = $(this).prop('value')
})
})