Shares of Dollar Tree Inc. rallied Wednesday — and were on track for their best year since 2010 — after the off-price retailer beat Wall Street’s expectations on all key financial metrics for the fiscal third quarter, with the company saying that its assortment of products is attracting more wealthy customers.