Virginia’s state Capitol (Marvin Joseph/The Washington Post)

Political parties would no longer be able to require voters to sign loyalty pledges before participating in state-run presidential primaries under a bill that cleared the Virginia Senate with bipartisan support on Monday.

The loyalty pledge came under attack this winter from GOP presidential candidate Donald Trump, who called it a “suicidal mistake” that would alienate voters fed up with traditional party politics — the very newcomers who might be drawn to his unconventional presidential bid.

Amid the outcry that Trump helped generate, the state GOP recently scrapped its plans to use a loyalty pledge in the March 1 presidential primary. But the party’s Jan. 30 about-face came so late that thousands of absentee ballots had already been cast.

The bill that passed the Senate Monday includes an emergency clause that would allow the law to take effect in time for that primary, assuming it clears the House and gets the signature of Gov. Terry McAuliffe (D). If it does take effect, lawmakers said, that would ensure that absentee ballots are counted regardless of whether a voter signed the oath.

The oaths have been proposed several times in recent years in Virginia and several other states where voters do not register by party affiliation.

Supporters of the GOP pledge in Virginia said it would help deter Democratic mischief-makers who want to meddle in GOP primaries.

But Trump and others said it could act as a deterrent to voters who are frustrated with the Republican establishment.

The Virginia law, sponsored by Sen. J. Chapman “Chap” Petersen (D-Fairfax), would apply only to state-run presidential primaries, so oaths could still be required for state-run primaries pertaining to other contests, such as the 2017 governor’s race. Oaths could also be required for presidential nominations handled through party conventions or mass meetings.

Petersen’s bill passed the Senate by a 34-to-5 vote, with Sen. Thomas Garrett (R-Buckingham) not voting. Only one Democrat voted against the bill, Sen. Creigh Deeds of Bath.

Deeds said he thought the measure might deter parties from picking their candidates through primaries, which are easier to participate in than conventions. Party conventions are day-long events that require participants to travel from across the state to one central meeting spot.

“I think we ought to be about promoting use of primaries,” Deeds said.

The Senate also passed a bill Monday that would require that candidates names in general elections be listed on the ballot along with the party that nominated them — something that is not currently done in Virginia.

The measure would not apply to nominees for non-partisan offices such as school board, even if political parties make endorsements in those races.

The bill, which passed on a 24-to-16 vote, was sponsored by freshman Sen. David R. Suetterlein (R-Roanoke).