##// END OF EJS Templates
SVG: scoped is passed as metadata...
Pablo de Oliveira -
Show More
@@ -395,8 +395,6 b' class SVG(DisplayObject):'
395 def data(self):
395 def data(self):
396 return self._data
396 return self._data
397
397
398 _scoped_class = "ipython-scoped"
399
400 @data.setter
398 @data.setter
401 def data(self, svg):
399 def data(self, svg):
402 if svg is None:
400 if svg is None:
@@ -409,12 +407,6 b' class SVG(DisplayObject):'
409 # get svg tag (should be 1)
407 # get svg tag (should be 1)
410 found_svg = x.getElementsByTagName('svg')
408 found_svg = x.getElementsByTagName('svg')
411 if found_svg:
409 if found_svg:
412 # If the user requests scoping, tag the svg with the
413 # ipython-scoped class
414 if self.scoped:
415 classes = (found_svg[0].getAttribute('class') +
416 " " + self._scoped_class)
417 found_svg[0].setAttribute('class', classes)
418 svg = found_svg[0].toxml()
410 svg = found_svg[0].toxml()
419 else:
411 else:
420 # fallback on the input, trust the user
412 # fallback on the input, trust the user
@@ -424,7 +416,11 b' class SVG(DisplayObject):'
424 self._data = svg
416 self._data = svg
425
417
426 def _repr_svg_(self):
418 def _repr_svg_(self):
427 return self.data
419 if self.scoped:
420 metadata = dict(scoped=True)
421 return self.data, metadata
422 else:
423 return self.data
428
424
429
425
430 class JSON(DisplayObject):
426 class JSON(DisplayObject):
@@ -498,7 +498,7 b' var IPython = (function (IPython) {'
498 wrapper.append(svg);
498 wrapper.append(svg);
499 var svg_element = wrapper.children()[0];
499 var svg_element = wrapper.children()[0];
500
500
501 if (svg_element.classList.contains('ipython-scoped')) {
501 if (md['scoped']) {
502 // To avoid style or use collisions between multiple svg figures,
502 // To avoid style or use collisions between multiple svg figures,
503 // svg figures are wrapped inside an iframe.
503 // svg figures are wrapped inside an iframe.
504 var iframe = $('<iframe/>')
504 var iframe = $('<iframe/>')
General Comments 0
You need to be logged in to leave comments. Login now