Ahmad ibn Muhammad narrated from Ali ibn al-Hakam, from Aban ibn Uthman, from Bukayr ibn A‘yan, from one of the two Imams عليه السلام, who said:
Imam عليه السلام said: "If an impurity occurs in the mosque, there is no harm in performing ablution in the mosque."
Ali Akbar al-Ghaffari
Tahdhīb al-Aḥkām fī Sharḥ al-Muqniʿah, vol. 1, p. 375