Auto merge of #21533 - nupurbaghel:current_src, r=jdm

correct currentSrc function

<!-- Please describe your changes on the following line: -->

---
(recreating PR which got closed earlier https://github.com/servo/servo/pull/21521)
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21533)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-09-01 09:03:30 -04:00 committed by GitHub
commit ad865c7156
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 69 deletions

View file

@ -1147,10 +1147,16 @@ impl HTMLImageElementMethods for HTMLImageElement {
// https://html.spec.whatwg.org/multipage/#dom-img-currentsrc
fn CurrentSrc(&self) -> DOMString {
let ref url = self.current_request.borrow().source_url;
let ref url = self.current_request.borrow().parsed_url;
match *url {
Some(ref url) => url.clone(),
None => DOMString::from(""),
Some(ref url) => DOMString::from_string(url.clone().into_string()),
None => {
let ref unparsed_url = self.current_request.borrow().source_url;
match *unparsed_url {
Some(ref url) => url.clone(),
None => DOMString::from("")
}
},
}
}