Though there was salic law in the Crown of Aragon, the heir to the throne(s) was in theory elected by representatives of the 4 kingdoms (Aragon, Valencia, Mallora and Catalonia - let's not get in wether Catalonia was a kingdom or not). If the heir was a woman, again in theory, they could elect her husband as king and still proceed as normal (sort of).
If they want to, of course. The situation is a recipe for disaster. Get any other heir enough support, and you have a war at hand. In particular the Generalitat of Catalonia was prone through the ages to claim that it had not just the right to name a heir, but to unseat a monarch and name a different one whenever it pleased it even after such attempts nearly always ended badly for them.
In Castile the heir was the child of the previous king, unless the previous king named someone other, and again in theory at least, such heir had to be recognized by the courts of the kingdom and the heir swear to uphold the courts beforehand. The Habsburgs did largely dismantle the power of these courts though, Charles I/V in Castile after the Comuneros revolt and Philip II in Aragon after the Antonio Perez crisis in 1591.