Which seems to support your idea! "Capital gains are sourced to your place of residence."
Any dividend income would be taxable, since you have to file an IRS return for all ex-PR income, but it looks like not the CG.
Quite a loophole - thanks for prompting the research.
EDIT: There are some quite long-term residency requirements to avoid CG on things you owned before moving to PR though. I don't think it'd work in the year timeframe you asked about.
"In general, United States citizens and resident aliens who are bona fide residents of Puerto Rico during the entire tax year, which for most individuals is January 1 to December 31, are not required to file a U.S. federal income tax return if they have income only from sources within Puerto Rico." www.irs.gov/taxtopics/tc901.html
There are caveats. One that I know for sure is that if you are self-employed, you still must file & pay FICA taxes to the US federal government.
(Note: I don't know specifically about Puerto Rico, but generally the above is the case for US citizens in foreign countries.)