{"action":"closed","issue":{"url":"https://api.github.com/repos/zhangxinxu/mobilebone/issues/144","labels_url":"https://api.github.com/repos/zhangxinxu/mobilebone/issues/144/labels{/name}","comments_url":"https://api.github.com/repos/zhangxinxu/mobilebone/issues/144/comments","events_url":"https://api.github.com/repos/zhangxinxu/mobilebone/issues/144/events","html_url":"https://github.com/zhangxinxu/mobilebone/issues/144","id":74266921,"number":144,"title":"当ajax请求页面时，response中包含svg文件时，页面title会失效","user":{"login":"woaixiangbao","id":1953879,"avatar_url":"https://avatars.githubusercontent.com/u/1953879?v=3","gravatar_id":"","url":"https://api.github.com/users/woaixiangbao","html_url":"https://github.com/woaixiangbao","followers_url":"https://api.github.com/users/woaixiangbao/followers","following_url":"https://api.github.com/users/woaixiangbao/following{/other_user}","gists_url":"https://api.github.com/users/woaixiangbao/gists{/gist_id}","starred_url":"https://api.github.com/users/woaixiangbao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woaixiangbao/subscriptions","organizations_url":"https://api.github.com/users/woaixiangbao/orgs","repos_url":"https://api.github.com/users/woaixiangbao/repos","events_url":"https://api.github.com/users/woaixiangbao/events{/privacy}","received_events_url":"https://api.github.com/users/woaixiangbao/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-08T07:34:37Z","updated_at":"2015-05-30T10:20:13Z","closed_at":"2015-05-30T10:20:13Z","body":"事情是这样的，当转场是通过ajax去请求新的page页面，而这个新的page页面只是html片段，并不包含head和body之类的，只是一个div。那么，当这个div中包含svg文件（svg文件指的是SVG Sprite文件，你博客中介绍过，而这类代码中一般会包含< title > xxx< / title >标签的。这样就会导致Mobilebone.createPage 这个方法中的create_page.setAttribute(\"data-title\", create_title.innerText);这个失效。因为xml中的标签没有innerText方法。\r\n\r\n所以。。。难道还要判断一下是否是SVGTitleElement才行？\r\n\r\n我现在是遇到了这样的问题，因为转场请求过来的页面中包含svg，所以即使设置了data-title什么的都不管用，都会返回undefined，不仅如此，这个undefined还是个字符串，所以在你源码的第285行：\r\n\r\nif (title) {\r\n\t\t\t\tdocument.title = title;\r\n\t\t\t\tif (header) {\r\n\t\t\t\t\theader.innerHTML = title;\r\n\t\t\t\t\theader.title = title;\r\n\t\t\t\t}\r\n\t\t\t} else if (first_page == pageInto && !pageOut && document.title) {\r\n\t\t\t\t// set data-title for first visibie page\r\n\t\t\t\tpageInto.setAttribute(\"data-title\", document.title);\r\n\t\t\t}\r\n\r\n还是会走到if块里面去，所以最终依然页面的标题是undefined。\r\n\r\n不知道我有没有描述清楚，大概就是这样了。"}}